fs.writeFileSync(baseTemplatePath, '<div>base-template</div>'); fs.writeFileSync(testTemplatePath, '<div>test</div>'); });
saveSettings(settings) { for (let option in settings) { let value = settings[option]; this.setOption(option, value); } const json = JSON.stringify(this.custom, null, 2); fs.writeFileSync(`${this.directory}${this.filename}`, json, "utf-8"); // reload settings as it does some critical checks this.loadSettings(); }
function compress(fileName, options) { // encode some data with options (default options shown) const folderPath = path.join(__dirname, '..', 'brotli', 'testdata'); const filePath = path.join(folderPath, fileName); const buffer = brotli.compress(fs.readFileSync(filePath), options); // Cleanup if (fs.exists(path.join(folderPath, `${fileName}.br`))) { fs.unlinkSync(path.join(folderPath, `${fileName}.br`)); fs.unlinkSync(path.join(folderPath, `uncompressed-${fileName}`)); } fs.writeFileSync(path.join(folderPath, `${fileName}.br`), buffer); }
generators.extend({ // The name `constructor` is important here constructor: function() { // Calling the super constructor is important so our generator is correctly set up generators.apply(this, arguments); }, method: function() { console.log('UPDATING JSON File: ', this.options.filePath); var config = Object.assign(require(this.options.filePath), this.options.replace); fs.writeFileSync(this.options.filePath, JSON.stringify(config, null, 2)); this.log(chalk.green('Updating: ', this.options.filePath)); } })
const copySync = (src, dest, overwrite) => { if (overwrite && fs.existsSync(dest)) { fs.unlinkSync(dest); } const data = fs.readFileSync(src); fs.writeFileSync(dest, data); }
function generate(cwd, config) { fs.writeFileSync(path.join(cwd, config.output.file), ejs.render(fs.readFileSync(path.join(__dirname, '..', '..', config.template), { encoding: 'utf-8' }), config.params)); }
function decompress(fileName) { const folderPath = path.join(__dirname, '..', 'brotli', 'testdata'); const filePath = path.join(folderPath, fileName); // Cleanup if (fs.exists(path.join(folderPath, `uncompressed-${fileName}`))) { fs.unlinkSync(path.join(folderPath, `uncompressed-${fileName}`)); } const decompressedBuffer = brotli.decompress( fs.readFileSync(path.join(folderPath, `${fileName}.br`)) ); fs.writeFileSync(path.join(folderPath, `uncompressed-${fileName}`), decompressedBuffer, 'UTF-8'); }
/* ------------------------- SCRIPT ------------------------- */ ipcMain.on("script:copy", function (_, script, filename) { let pathTemp = path.join(_baseFolder, filename); console.log("Saving script to " + pathTemp); fs.writeFileSync(pathTemp, script) console.log("Running " + pathTemp); exec("bash \"" + pathTemp + "\""); });
function generate(cwd, config) { fs.writeFileSync(path.join(cwd, config.output.file), ejs.render(fs.readFileSync(require.resolve(__dirname + "/../../" + config.template), { encoding: 'utf-8' }), config.params)); }
const copySync = (src, dest, overwrite) => { if (overwrite && fs.existsSync(dest)) { fs.unlinkSync(dest); } const data = fs.readFileSync(src); fs.writeFileSync(dest, data); }
const copySync = (src, dest, overwrite) => { if (overwrite && fs.existsSync(dest)) { fs.unlinkSync(dest); } const data = fs.readFileSync(src); fs.writeFileSync(dest, data); }
const copySync = (src, dest, overwrite) => { if (overwrite && fs.existsSync(dest)) { fs.unlinkSync(dest); } const data = fs.readFileSync(src); fs.writeFileSync(dest, data); }
const copySync = (src, dest, overwrite) => { if (overwrite && fs.existsSync(dest)) { fs.unlinkSync(dest); } const data = fs.readFileSync(src); fs.writeFileSync(dest, data); }
const copySync = (src, dest, overwrite) => { if (overwrite && fs.existsSync(dest)) { fs.unlinkSync(dest); } const data = fs.readFileSync(src); fs.writeFileSync(dest, data); }
generators.extend({ // The name `constructor` is important here constructor: function () { // Calling the super constructor is important so our generator is correctly set up generators.apply(this, arguments); }, method: function () { console.log('UPDATING JSON File: ', this.options.filePath); var config = Object.assign(require(this.options.filePath), this.options.replace); fs.writeFileSync(this.options.filePath, JSON.stringify(config, null, 2)); this.log(chalk.green('Updating: ', this.options.filePath)); } })