async function main() { const projectName = 'joplin-android'; const newContent = updateGradleConfig(); const version = gradleVersionName(newContent); const tagName = 'android-v' + version; const apkFilename = 'joplin-v' + version + '.apk'; const apkFilePath = releaseDir + '/' + apkFilename; const downloadUrl = 'https://github.com/laurent22/' + projectName + '/releases/download/' + tagName + '/' + apkFilename; process.chdir(rootDir); console.info('Running from: ' + process.cwd()); console.info('Building APK file...'); const output = await execCommand('/mnt/c/Windows/System32/cmd.exe /c "cd ReactNativeClient\\android && gradlew.bat assembleRelease -PbuildDir=build --console plain"'); console.info(output); await fs.mkdirp(releaseDir); console.info('Copying APK to ' + apkFilePath); await fs.copy('ReactNativeClient/android/app/build/outputs/apk/app-release.apk', apkFilePath); console.info('Updating Readme URL...'); let readmeContent = await fs.readFile('README.md', 'utf8'); readmeContent = readmeContent.replace(/(https:\/\/github.com\/laurent22\/joplin-android\/releases\/download\/.*?\.apk)/, downloadUrl); await fs.writeFile('README.md', readmeContent); console.info(await execCommand('git pull')); console.info(await execCommand('git add -A')); console.info(await execCommand('git commit -m "Android release v' + version + '"')); console.info(await execCommand('git tag ' + tagName)); console.info(await execCommand('git push')); console.info(await execCommand('git push --tags')); console.info('Creating GitHub release ' + tagName + '...'); const release = await githubRelease(projectName, tagName, false); const uploadUrlTemplate = uriTemplate.parse(release.upload_url); const uploadUrl = uploadUrlTemplate.expand({ name: apkFilename }); const binaryBody = await fs.readFile(apkFilePath); const oauthToken = await githubOauthToken(); console.info('Uploading ' + apkFilename + ' to ' + uploadUrl); const uploadResponse = await fetch(uploadUrl, { method: 'POST', body: binaryBody, headers: { 'Content-Type': 'application/vnd.android.package-archive', 'Authorization': 'token ' + oauthToken, 'Content-Length': binaryBody.length, }, }); const uploadResponseText = await uploadResponse.text(); console.info(uploadResponseText); }
const copy = (starterPath, rootPath, callback) => { const copyDirectory = () => { fs.copy(starterPath, rootPath, { filter: ignored }, (error) => { if (error !== null) return callback(new Error(error)) logger.log('Created starter directory layout') install(rootPath, callback) return false }) } // Chmod with 755. // 493 = parseInt('755', 8) fs.mkdirp(rootPath, { mode: 493 }, (error) => { if (error !== null) callback(new Error(error)) return fsexists(starterPath, (exists) => { if (!exists) { const chmodError = `starter ${starterPath} doesn't exist` return callback(new Error(chmodError)) } logger.log(`Copying local starter to ${rootPath} ...`) copyDirectory() return true }) }) }
process.on("message", function (message) { message.success = function (result) { _success(result); }; if (message._compiler === "ruby") { // Create output directory before running ruby compiler fs.mkdirp(path.dirname(message.outFile), function () { ruby.render(message); }); } else { // "libsass" message.error = function (sassError) { var details = {}; details.errorString = sassError.message; details.path = sassError.file; details.pos = { line: sassError.line - 1, ch: sassError.column }; details.message = sassError.message; process.send({ error: details }); }; sass.render(message); } });
PastLevel.prototype._levelup = function(dbPath, opts, cb) { fse.mkdirp(path.dirname(dbPath), function(err) { if(err) return cb(err); levelup(dbPath, opts, cb); }); };
bundleDirDef.then(function() { mkdirp(dirname(bundlePath), function(err) { if (err) { reject(err); } else { fs.writeFile(bundlePath, code, function(err) { if(err) { reject(err); } else { if(!map) { resolve(bundle); return; } // Write out the source map fs.writeFile(bundlePath+".map", map, function(err) { if(err) return reject(err); resolve(bundle); }); } }); } }); }).catch(function(err) {
fs.remove(to, function () { fs.mkdirp(path.dirname(to), function () { fs.copy(from, to, function (err) { return done(err && new Error('Failed to copy directory: ' + err)) }) }) })
function processAlbum(album, index){ try{ var albumJson = fs.readFileSync(path.join(ALBUM_DATA_FOLDER, album.id, 'index.json'), 'utf-8'), albumData = JSON.parse(albumJson); //create album dir in the pictures folder fs.mkdirp(path.join(ALBUM_PICTURE_FOLDER, album.id), function albumPhotoDirCreated(err, folder) { if (err) { console.error(err); } //walk all phtotos in an album albumData.photos.data.forEach( function addPhotoToQueue(photo,index){ photoQueue.push({ 'album_id': album.id, 'photo_id': photo.id, 'url': photo.images[PICTURE_SIZE].source }); }// addPhotoToQueue ); //check if all photos were included in the queue if (++albumsProcessed == albumListData.albums.data.length){ console.log('start unqueueing'); requestInterval = setInterval(downloadNextPhoto, WAIT_DOWNLOAD); } } ); }catch(e){ albumsProcessed++; if(e.errno == 34){ console.log('empty album'); }else{ console.log(e); } } }
async function setupDatabaseAndSynchronizer(id = null) { if (id === null) id = currentClient_; await setupDatabase(id); EncryptionService.instance_ = null; DecryptionWorker.instance_ = null; await fs.remove(resourceDir(id)); await fs.mkdirp(resourceDir(id), 0o755); if (!synchronizers_[id]) { const SyncTargetClass = SyncTargetRegistry.classById(syncTargetId_); const syncTarget = new SyncTargetClass(db(id)); syncTarget.setFileApi(fileApi()); syncTarget.setLogger(logger); synchronizers_[id] = await syncTarget.synchronizer(); synchronizers_[id].autoStartDecryptionWorker_ = false; // For testing we disable this since it would make the tests non-deterministic } encryptionServices_[id] = new EncryptionService(); decryptionWorkers_[id] = new DecryptionWorker(); decryptionWorkers_[id].setEncryptionService(encryptionServices_[id]); await fileApi().clearRoot(); }
async function generateFirebaseFolder() { await fs.mkdirp('firebase'); if (argv.file) { log(colors.green(`Processing file: ${argv.file}.`)); log(colors.green('Writing file to firebase.index.html.')); await fs.copyFile(/*src*/ argv.file, 'firebase/index.html', {overwrite: true}); await replaceUrls('firebase/index.html'); } else { await Promise.all([ copyAndReplaceUrls('test/manual', 'firebase/manual'), copyAndReplaceUrls('examples', 'firebase/examples'), ]); } log(colors.green('Copying local amp files from dist folder.')); await Promise.all([ fs.copy('dist', 'firebase/dist', {overwrite: true}), fs.copy('dist.3p/current', 'firebase/dist.3p/current', {overwrite: true}), ]); await Promise.all([ modifyThirdPartyUrl(), fs.copyFile('firebase/dist/ww.max.js', 'firebase/dist/ww.js', {overwrite: true}), ]); }
newFB.save(function(err, user){ if (err) return err; fse.mkdirp('permanent/users/facebook/'+newFB.facebook.id, function(err){ if(err) throw err }); return done(null, user); });
app.get('/save', function (req, res) { var html = req.query.html; var outputDir = path.join(app.get('user'), 'saved'); var name = sh.unique(html); fs.mkdirp(outputDir, function (err) { if (err) return console.error(err); fs.writeFile(path.join(outputDir, name + ".html"), html, function(err) { if(err){ console.log(err); res.send({ success: false }); return; } res.send({ success: true, name: name }); }); }); });
Icon.prototype.create = function(icon, callback) { var relativePath = createIconPath(this, icon.name); var newIcon = { eventId: this._eventId, formId: this._formId, primary: this._primary, variant: this._variant, relativePath: relativePath }; var iconPath = path.join(iconBase, relativePath); fs.mkdirp(path.dirname(iconPath), function(err) { if (err) return callback(err); fs.rename(icon.path, iconPath, function(err) { if (err) return callback(err); IconModel.create(newIcon, function(err, oldIcon) { callback(err, newIcon); if (oldIcon && oldIcon.relativePath !== newIcon.relativePath) { fs.remove(path.join(iconBase, oldIcon.relativePath), function(err) { if (err) log.error('could not remove old icon from file system', err); }); } }); }); }); };
constructor() { this._desktopConfigPath = path.join(app.getPath('userData'), 'conf.json') this._onValueSetListeners = {} try { this._buildConfig = require(path.join(app.getAppPath(), 'package.json'))['tutao-config'] } catch (e) { app.once('ready', () => { dialog.showMessageBox(null, { type: 'error', buttons: ['Ok'], defaultId: 0, // no lang yet title: 'Oh No!', message: `Couldn't load config: \n ${e.message}` }) process.exit(1) }) return } try { this._desktopConfig = this._buildConfig["defaultDesktopConfig"] const userConf = fs.existsSync(this._desktopConfigPath) ? fs.readJSONSync(this._desktopConfigPath) : {} this._desktopConfig = Object.assign(this._desktopConfig, userConf) fs.mkdirp(path.join(app.getPath('userData'))) fs.writeJSONSync(this._desktopConfigPath, this._desktopConfig, {spaces: 2}) } catch (e) { this._desktopConfig = this._buildConfig["defaultDesktopConfig"] console.error("Could not create or load desktop config:", e.message) } }
test('setup', function (t) { fs.mkdirp(WORK_CWD, function (err) { if (err) t.end(err) process.chdir(WORK_CWD) t.end() }) })
LDP.prototype.put = function (host, resourcePath, stream, callback) { var ldp = this var root = !ldp.idp ? ldp.root : ldp.root + host + '/' var filePath = utils.uriToFilename(resourcePath, root, host) // PUT requests not supported on containers. Use POST instead if (filePath[filePath.length - 1] === '/') { return callback(error(409, 'PUT not supported on containers, use POST instead')) } mkdirp(path.dirname(filePath), function (err) { if (err) { debug.handlers('PUT -- Error creating directory: ' + err) return callback(error(err, 'Failed to create the path to the new resource')) } var file = stream.pipe(fs.createWriteStream(filePath)) file.on('error', function () { callback(error(500, 'Error writing data')) }) file.on('finish', function () { debug.handlers('PUT -- Wrote data to: ' + filePath) callback(null) }) }) }
before(function(done){ fse.mkdirp(path.join(__dirname, "temp"), function(){ fse.mkdirSync(path.join(__dirname, "temp", "myproj")) fse.mkdirSync(path.join(__dirname, "temp", "foo")) fse.writeFileSync(path.join(__dirname, "temp", "bar"), "hello bar") done() }) })
before(function (done) { var dir = path.join(config.paths.assets.output, 'js') fse.mkdirp(dir, function (err) { assert.ifError(err) fs.writeFileSync(path.join(dir, 'to-remove.js'), 'test') done() }) })
fs.exists(path, function(exists) { if(!exists) return callback(); fs.mkdirp(settings.templateStageDir, function(err) { if(err) return callback(err); console.log("adding templates from: " + path); fs.copy(path, settings.templateStageDir, callback); }); });
gulp.task('release-clean', async () => { if (!await fs.exists(RELEASE_PATH)) { await fs.mkdirp(RELEASE_PATH); } const files = (await fs.readdir(RELEASE_PATH)).filter(file => !/^\./.test(file)); for (const file of files) { await fs.remove(path.resolve(RELEASE_PATH, file)); } });
fs.mkdirp(path.join(stageDir, 'files'), function(err) { if(err) return callback(err); fs.mkdirp(path.join(stageDir, 'config_files'), function(err) { if(err) return callback(err); fs.mkdirp(path.join(stageDir, 'postscripts'), function(err) { callback(null); }); }); });
self.generate = function(target, callback) { fs.mkdirp(target, function(error) { if (error) { callback(error); } else { fs.readdir(template, function(error, files) { if (error) { callback(error); } else { var checklist = new Checklist(files, callback); files.forEach(function(file) { var templatePath = template + '/' + file; var targetName = file; if (replacements) { replacements.forEach(function(replacement) { targetName = targetName.replace(new RegExp(replacement.what, 'g'), replacement.with); }); } var targetPath = target + '/' + targetName; fs.stat(templatePath, function(error, stat) { if (error) { checklist.check(file, error); } else { if (stat.isDirectory()) { var boilerplate = new Boilerplate(templatePath, replacements); boilerplate.generate(targetPath, function(error) { checklist.check(file, error); }); } else { if (replacements) { fs.readFile(templatePath, 'utf8', function(error, buffer) { if (error) { checklist.check(file, error); } else { replacements.forEach(function(replacement) { buffer = buffer.replace(new RegExp(replacement.what, 'g'), replacement.with); }); fs.writeFile(targetPath, buffer, 'utf8', function(error) { checklist.check(file, error); }); } }); } else { fs.copy(templatePath, targetPath, function(error) { checklist.check(file, error); }); } } } }); }); } }); } }); };
getDuration(response, url, file, mediaID, type, function(duration){ fs.mkdirp("./public/data/"+type+"/", function(err) { // Check if subtitles exist and write them to data folder if(fs.existsSync(subtitleUrl)){ var subOutput = "./public/data/"+type+"/"+subtitleTitle; fs.writeFileSync(subOutput, fs.readFileSync(subtitleUrl)); hasSub = true; } checkProgression(mediaID, type, function(data){ if(data.transcodingstatus === 'pending' || data.transcodingstatus === undefined){ logger.warn('Previously transcoding of this file was not completed'); if(fs.existsSync(url)){ if(filetype === 'mp4'){ if(fs.existsSync(outputPathWebFriendly)){ fs.unlinkSync(outputPathWebFriendly); } logger.info('File is mp4, copieing local file to data folder so it can be accessed...'); fs.copySync(url, outputPathWebFriendly); } else { fs.exists(transcodePath, function(exists){ if(exists && !CurrentTranscodings.isTranscoding(url)){ fs.unlinkSync(transcodePath); } logger.info('Getting ready to start playing '+file+' on '+platform); startTranscoding(mediaID, type, response,url,platform, file, transcodePath, ExecConfig); }); } } else{ logger.warn('File '+ url + 'not found, did you move or delete it?'); } } else { logger.info('File '+file+' already trancoded with quality level: '+config.quality +'. Continuing with playback.'); } var fileLocation = outputPath; if(filetype === 'mp4'){ fileLocation = outputPathWebFriendly; } var fileInfo = { 'outputPath' : fileLocation, 'duration' : duration, 'progression' : data.progression, 'subtitle' : hasSub } if(platform === 'desktop'){ response.json(fileInfo); } }); }); });
function install() { fs.mkdirp(path.join(globalDir, 'node_modules'), function () { context.cmd({ cmd: {command: npm, args: ['install', '--color=always'].concat(globals), screen: 'npm install -g'}, cwd: globalDir }, function (err) { return done(err) }) }) }
export async function releaseClean() { if (!(await fs.exists(RELEASE_PATH))) { await fs.mkdirp(RELEASE_PATH); } const files = (await fs.readdir(RELEASE_PATH)).filter( file => (!/^\./.test(file)), ); for (const file of files) { await fs.remove(path.resolve(RELEASE_PATH, file)); } }
beforeEach(function (done) { opts = { pathToOutput: "./tmp", pathToImages: "images", loRes: false, loResDPI: 96, hiResDPI: 300 }; fs.mkdirp(opts.pathToOutput, done); });
var copyFile = function(file, done){ var ext = path.extname(file) if(!terraform.helpers.shouldIgnore(file) && [".jade", ".ejs", ".md", ".styl", ".less", ".scss", ".sass", ".coffee"].indexOf(ext) === -1){ var localPath = path.resolve(outputPath, file) fs.mkdirp(path.dirname(localPath), function(err){ fs.copy(path.resolve(setup.publicPath, file), localPath, done) }) }else{ done() } }
compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync(ID, async (data, cb) => { // get stats, write to disk await fs.ensureDir(this.targetDir) const htmlName = path.basename(data.plugin.options.filename) // Watch out for output files in sub directories const htmlPath = path.dirname(data.plugin.options.filename) const tempFilename = path.join(this.targetDir, htmlPath, `legacy-assets-${htmlName}.json`) await fs.mkdirp(path.dirname(tempFilename)) await fs.writeFile(tempFilename, JSON.stringify(data.body)) cb() })
ConfigFile.prototype.save = function(cb) { var configFile = this; if(!this.path) return cb(new Error('no path specified')); var absolutePath = configFile.getAbsolutePath(); configFile.data = configFile.data || {}; debug('output [%s] %j', absolutePath, configFile.data); fs.mkdirp(path.dirname(absolutePath), function(err) { if(err) return cb(err); fs.writeJson(absolutePath, configFile.data, cb); }); }
var fileData = fs.readFile(fromTemplate, {encoding: 'utf8'}, function(err, data) { if(err) return callback(err); var template = underscore.template(data); var compiledData = template(config); fs.mkdirp(path.dirname(toFile), function(err) { if(err) return callback("Could not create staging directory for compiled template"); fs.writeFile(toFile, compiledData, { mode: stats.mode }, callback); }); });
exports.prime = function(primePath, options, callback){ if(!callback){ callback = options options = {} } /** * Options (only one) */ var ignorePath = options.ignore ? path.resolve(primePath, options.ignore) : null // Absolute paths are predictable. var primePath = path.resolve(primePath) fse.mkdirp(primePath, function(){ fse.readdir(primePath, function(error, contents){ /** * Delete each item in the directory in parallel. Thanks Ry! */ if(contents.length == 0) return callback() var total = contents.length var count = 0 contents.forEach(function(i){ var filePath = path.resolve(primePath, i) var gitRegExp = new RegExp(/^.git/) /** * We leave `.git`, `.gitignore`, and project path. */ if(filePath === ignorePath || i.match(gitRegExp)){ count++ if(count == total) callback() }else{ fse.remove(filePath, function(err){ count++ if(count == total) callback() }) } }) }) }) }