async persistSources(sourceContainer, packageVersions) { const sources = sourceContainer.outputSources(); await Promise.all(sources.map((file) => fs.outputFile(path.join(this.appPath, file.fileName), file.content))); const packageJson = fs.readJsonSync(path.join(this.appPath, 'package.json')); packageJson.cubejsTemplates = { ...packageJson.cubejsTemplates, ...packageVersions, }; await fs.writeJson(path.join(this.appPath, 'package.json'), packageJson, { spaces: 2, }); }
async save ( cluster ) { const data = await cluster.getData() const row = [ cluster.id ] if ( ! command.zimlib4Fix ) { const offset = await out.write( data ) row.push( offset.toString() ) // convert BigInt to String } else { // zimlib4Fix stores clusters in separate files await fs.outputFile( osPath.join( this.savePrefix, `${cluster.id}` ), data ) row.push( data.length ) // cluster sizes instead of offsets } await wikiDb.run( 'INSERT INTO clusters ( id, offset ) VALUES ( ?,? )', row ) log( 'Cluster saved', row ) }
storeData ( data ) { if ( data == null ) return const savePath = osPath.join( wiki.outPath, this.localPath()) log( '+', savePath ) return fs.outputFile( savePath, data ) }
fs.outputFile( path.resolve("output/index.html"), rds.renderToStaticMarkup(h(Page, {title: "Hello World!"})), () => console.log("Done!") );
// take the outputted string from step above, transpile with babel and output the file const buildJSFile = (component, fileName) => { console.log(`building ${fileName} component`); fs.outputFile(path.join(output, `${fileName}.js`), transpileCode(component)) }
write(file, data, next) { Async.series([ callback => { this.server.knownWrite = true; callback(); }, callback => { Fs.outputFile(this.server.path(file), data, callback); }, callback => { this.chown(file, callback); }, ], next); }
const saveBase64Img = async avatarBase64Img => { /* generate random icon for user */ const avatarImage = avatarBase64Img.split(";base64,").pop(); const avatarName = randomstring.generate().concat(".png"); const filePath = `./assets/${avatarName}`; await fse.outputFile(filePath, avatarImage, { encoding: "base64" }); let avatarurl = `${SERVER_URL}:${SERVER_PORT}/assets/${avatarName}`; //assume port would be 80 for production build if (NODE_ENV === "production") { avatarurl = `${SERVER_URL}/assets/${avatarName}`; } return avatarurl; }
fs.readFile(item, (err, buffer) => { if (err) { this.eventsHandler.dispatch('error', `Unable to read ${item}`); return; } const outputPath = path.resolve( `${this.config.output}/${path.dirname( relativePath )}/${path.basename(relativePath)}` ); fse.outputFile(outputPath, buffer, outputErr => { if (outputErr) { this.eventsHandler.dispatch( 'error', `Unable to save ${outputPath} file` ); } }); });
pullFile(uuid, next) { Log.debug({ egg: uuid }, 'Retrieving an updated egg from the Panel.'); Request({ method: 'GET', url: `${Config.get('remote.base')}/api/remote/eggs/${uuid}`, headers: { 'Accept': 'application/vnd.pterodactyl.v1+json', 'Authorization': `Bearer ${Config.get('keys.0')}`, }, }, (err, response, body) => { if (err) return next(err); if (response.statusCode !== 200) { return next(new Error(`Error while attempting to fetch updated Egg file (HTTP/${response.statusCode})`)); } Log.debug({ egg: uuid }, 'Writing new egg file to filesystem.'); Fs.outputFile(`./src/services/configs/${uuid}.json`, body, next); }); }
async function main() { const input = path.resolve(__dirname, 'src', 'jimp.js') const output = path.resolve(__dirname, 'dist', 'jimp.js') const pkg = path.resolve(__dirname, 'package.json') const opts = { cache: false, minify: true, sourceMapRegister: false } let { code } = await ncc(input, opts) code = code.replace(/new Buffer/g, 'new JIMPBUffer') await fs.outputFile(output, code) const { version } = require('jimp/package.json') await fs.writeJSON(pkg, { ...await fs.readJSON(pkg), version }, { spaces: 2 }) console.log('jimp-compact@' + version) }
Fs.stat('./config/.sftp/id_rsa', err => { if (err && err.code === 'ENOENT') { Log.info('Creating keypair to use for SFTP connections.'); const pair = Keypair({ bits: Config.get('sftp.keypair.bits', 2048), e: Config.get('sftp.keypair.e', 65537), }); Async.parallel([ pcall => { Fs.outputFile('./config/.sftp/id_rsa', pair.private, { mode: 0o600, }, pcall); }, pcall => { Fs.outputFile('./config/.sftp/id_rsa.pub', pair.public, { mode: 0o600, }, pcall); }, ], callback); } else if (err) { return callback(err); } else { return callback(); } });
async function build(env, entries) { log(`Creating ${env} build...`); const { entryFiles } = config; const webpackConfig = createWebpackConfig(env, entries); const stats = await webpackAsync(webpackConfig); console.log(stats.toString({ colors: true, excludeModules: true })); if (stats.hasErrors()) { log(`Failed to create ${env} build`, 2); process.exit(1); } const { entrypoints } = stats.toJson(); await outputFile(entryFiles[env], JSON.stringify(entrypoints)); log(`Successfully created ${env} build`); }
fs.outputFile(response.locals.localfilepath, fileData, function (err) {
async function processArticle ( articleIndex ) { if ( articles[ articleIndex ] != null ) return true // already processed const article = { index: articleIndex, offset: readUInt64LE( rawDirectory, articleIndex * 8 ) } await getDirEntry( article ) if ( article.mimeIdx == 0xfffe || article.mimeIdx == 0xfffd ) { // linktarget or deleted entry return true // noop } if ( article.mimeIdx == 0xffff ) { //redirect return storeRedirect( article ) } const moved = await renameBlob( article ) if (! moved ) return null const dom = await loadArticle( article ) if (! dom ) return null await alterLinks( article, dom ) return fs.outputFile( articlePath( article ), Buffer.from( dom.html() )) }
async function processArticle ( articleIndex ) { if ( articles[ articleIndex ] != null ) return true // already processed const article = { index: articleIndex, offset: readUInt64LE( rawDirectory, articleIndex * 8 ) } await getDirEntry( article ) if ( article.mimeIdx == 0xfffe || article.mimeIdx == 0xfffd ) { // linktarget or deleted entry return true // noop } if ( article.mimeIdx == 0xffff ) { //redirect return storeRedirect( article ) } const moved = await renameBlob( article ) if (! moved ) return null const dom = await loadArticle( article ) if (! dom ) return null await alterLinks( article, dom ) return fs.outputFile( articlePath( article ), Buffer.from( dom.html() )) }