function downloadChapter(chapterindex, lectureindex) { var num_lectures = coursedata["chapters"][chapterindex]["lectures"].length; var chapter_name = sanitize( chapterindex + 1 + ". " + coursedata["chapters"][chapterindex]["name"] ); mkdirp( download_directory + "/" + course_name + "/" + chapter_name, function() { downloadLecture(chapterindex, lectureindex, num_lectures, chapter_name); } ); }
// TODO: Move this to util, doesn't belong here createDirectory(options) { if (options.path) { mkdirp(options.path, error => { if (error) { console.trace('Error creating directory.', error); } }); } }
constructor({log = new Log(), cacheDir = path.join(os.tmpdir(), '.cache')} = {}) { // Get the nodecache opts super(); // Set some things this.log = log; this.cacheDir = cacheDir; // Ensure the cache dir exists mkdirp.sync(this.cacheDir); }
constructor() { this.tempPath = path.join(path.dirname(require.main.filename), '..', 'temp'); mkdirp(this.tempPath); }
// Ensure some dirs exist before we start _.forEach([caDir, sshDir], dir => mkdirp.sync(dir));
async function main() { mkdirp.sync(path.resolve(__dirname, '../../repositories/')); for (const [type, collection] of Object.entries(fetch)) { const result = await Promise.all(collection.map(async (item) => { if (typeof item === 'string') { return item; } const { organization, suffixes, hides } = item; const repos = await paginate(organization); return repos .map(repo => repo.full_name) .filter(name => suffixes.some(suffix => name.endsWith(suffix))) .filter(name => !hides.includes(name)); })); const json = JSON.stringify(_.flatten(result), undefined, 2); const jsonPath = path.resolve(__dirname, `../../repositories/${type}.json`); fs.writeFile(jsonPath, json, (err) => { if (err) { throw err; } }); } }
// If the proxy is on lets immediately dump the default certs and all of that app.events.on('pre-init', () => { lando.log.verbose('proxy is ON.'); lando.log.verbose('Setting the default proxy certificate %s', lando.config.proxyDefaultCert); // Create needed directories mkdirp.sync(lando.config.proxyConfigDir); const files = [{ path: path.join(lando.config.proxyConfigDir, 'default-certs.yaml'), data: {tls: {stores: {default: {defaultCertificate: { certFile: lando.config.proxyDefaultCert, keyFile: lando.config.proxyDefaultKey, }}}}}, }]; // Finally add in custom config if we have it if (!_.isEmpty(lando.config.proxyCustom)) { lando.log.verbose('adding custom proxy config'); lando.log.debug('custom proxy config', lando.config.proxyCustom); files.push({ path: path.join(lando.config.proxyConfigDir, 'user-custom.yaml'), data: lando.config.proxyCustom, }); } // Remove and redump all the files _.forEach(files, file => lando.yaml.dump(file.path, file.data)); });
/** * Dumps an object to a YAML file * * @since 3.0.0 * @alias lando.yaml.dump * @param {String} file The path to the file to be loaded * @param {Object} data The object to dump * @return {String} Flename */ dump(file, data = {}) { // Make sure we have a place to store these files mkdirp.sync(path.dirname(file)); // Remove any properties that might be bad and dump data = JSON.parse(JSON.stringify(data)); // And dump fs.writeFileSync(file, yaml.safeDump(data)); // Log and return filename return file; }
_.forEach(excludes, exclude => mkdirp.sync(path.join(app.root, exclude)));
mkdirp.sync(logDir);
const writeFile = (writePath, content, cb) => { mkdir(getDirName(writePath), err => { if (err) { return cb(err); } fs.writeFile(writePath, content, 'utf8', cb); return 0; }); }
const extractBuild = () => { const extractPath = path.resolve(this.cwd, opts.extract); mkdirp.sync(extractPath); const locales = confman.load(localesPath); utils.each(locales, (name, locale) => { locale.__name__ = name; const localeFile = path.normalize(`${extractPath}/${name}.js`); const localeCode = `window['${opts.key}']=${JSON.stringify(locale)};`; fs.writeFileSync(localeFile, localeCode); }); return { _t: Date.now() }; }
const extractBuild = () => { const extractPath = path.resolve(this.cwd, opts.extract); mkdirp.sync(extractPath); const locales = confman.load(localesPath); utils.each(locales, (name, locale) => { locale.__name__ = name; const localeFile = path.normalize(`${extractPath}/${name}.js`); const localeCode = `window['${opts.key}']=${JSON.stringify(locale)};`; fs.writeFileSync(localeFile, localeCode); }); return { _t: Date.now() }; }