Skip to content

Instantly share code, notes, and snippets.

@twhite96
Forked from yoav-lavi/require.js
Created May 5, 2019 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twhite96/741d44cfe07dafc149c6f4a2ff6ddcdd to your computer and use it in GitHub Desktop.
Save twhite96/741d44cfe07dafc149c6f4a2ff6ddcdd to your computer and use it in GitHub Desktop.
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: green; icon-glyph: file-code;
const getModule = importModule("getModule");
const documentDirectory = FileManager.iCloud().documentsDirectory();
module.exports = async ({ moduleName, url, forceDownload = false }) => {
if (moduleExists(moduleName) && !forceDownload) {
return importModule(moduleName);
}
return await getModule({ moduleName, url });
}
const moduleExists = (moduleName) => FileManager.iCloud().fileExists(`${documentDirectory}/${moduleName}.js`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment