Skip to content

Instantly share code, notes, and snippets.

@yoav-lavi
Created April 20, 2019 20:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yoav-lavi/7ea123f8c76f43dd131eb96530294142 to your computer and use it in GitHub Desktop.
Save yoav-lavi/7ea123f8c76f43dd131eb96530294142 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