How to use the fs-extra.writeFileSync function in fs-extra

To help you get started, we’ve selected a few fs-extra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fredsiika / 30-seconds-of-c / scripts / build.js View on Github external
misc.image('Logo', '/logo.png') +
      headers.h1('Snippets Archive') +
      "These snippets, while useful and interesting, didn't quite make it into the repository due to either having very specific use-cases or being outdated. However we felt like they might still be useful to some readers, so here they are." +
      headers.h2('Table of Contents');

    output += lists.ul(Object.entries(snippets), snippet =>
      misc.link(`\`${snippet[0].slice(0, -3)}\``, misc.anchor(snippet[0].slice(0, -3)))
    );
    output += misc.hr();

    for (const snippet of Object.entries(snippets)) {
      output += makeExamples(snippet[1]);
    }

    // Write to the README file of the archive
    fs.writeFileSync(path.join(SNIPPETS_ARCHIVE_PATH, 'README.md'), output);
  } catch (err) {
    console.log(`${chalk.red('ERROR!')} During README generation for snippets archive: ${err}`);
    process.exit(1);
  }

  console.log(`${chalk.green('SUCCESS!')} README file generated for snippets archive!`);
  console.timeEnd('Builder');
}
let snippets = {};
const EMOJIS = {
  adapter: '🔌',
  array: '📚',
  browser: '🌐',
  date: '⏱️',
  function: '🎛️',
  logic: '🔮',
github fusepilot / create-cep-extension / packages / create-cep-extension-scripts / scripts / eject.js View on Github external
}
      content =
        content
          // Remove dead code from .js files on eject
          .replace(
            /\/\/ @remove-on-eject-begin([\s\S]*?)\/\/ @remove-on-eject-end/gm,
            ''
          )
          // Remove dead code from .applescript files on eject
          .replace(
            /-- @remove-on-eject-begin([\s\S]*?)-- @remove-on-eject-end/gm,
            ''
          )
          .trim() + '\n';
      console.log(`  Adding ${cyan(file.replace(ownPath, ''))} to the project`);
      fs.writeFileSync(file.replace(ownPath, appPath), content);
    });
    console.log();
github apidoc / apidoc / lib / apidoc.js View on Github external
app.log.debug('create dir: ' + options.dest);
    if ( ! options.simulate)
        fs.mkdirsSync(options.dest);

    app.log.debug('copy template ' + options.template + ' to: ' + options.dest);
    if ( ! options.simulate)
        fs.copySync(options.template, options.dest);

    // Write api_data
    app.log.debug('write json file: ' + options.dest + 'api_data.json');
    if( ! options.simulate)
        fs.writeFileSync(options.dest + './api_data.json', apiData);

    app.log.debug('write js file: ' + options.dest + 'api_data.js');
    if( ! options.simulate)
        fs.writeFileSync(options.dest + './api_data.js', 'define({ "api": ' + apiData + ' });');

    // Write api_project
    app.log.debug('write json file: ' + options.dest + 'api_project.json');
    if( ! options.simulate)
        fs.writeFileSync(options.dest + './api_project.json', apiProject);

    app.log.debug('write js file: ' + options.dest + 'api_project.js');
    if( ! options.simulate)
        fs.writeFileSync(options.dest + './api_project.js', 'define(' + apiProject + ');');

    return true;
}
github pmkary / Orchestra / gulpfile.js View on Github external
// loading the info file
        const plistFileString =
            fs.readFileSync( plistFilePath, 'utf8' )
        const infoJSON =
            plist.parse( plistFileString )

        // adding stuff to the plist data
        const newInfoJSON =
            Object.assign( infoJSON, darwinInfoPlistBase )

        // making new plist info
        const newPlistFileString =
            plist.build( newInfoJSON )

        // done, now saving it back
        fs.writeFileSync( plistFilePath, newPlistFileString )
    }
github fusepilot / create-cep-extension / packages / create-cep-extension / createCEPExtension.js View on Github external
console.log(
      `The directory ${chalk.green(name)} contains files that could conflict.`
    );
    console.log('Try using a new directory name.');
    process.exit(1);
  }

  console.log(`Creating a new CEP extension in ${chalk.green(root)}.`);
  console.log();

  const packageJson = {
    name: appName,
    version: '0.1.0',
    private: true,
  };
  fs.writeFileSync(
    path.join(root, 'package.json'),
    JSON.stringify(packageJson, null, 2)
  );
  const originalDirectory = process.cwd();
  process.chdir(root);

  run(root, appName, version, verbose, originalDirectory, template);
}
github vuejs / vuepress / packages / @vuepress / shared-utils / scripts / update-index.js View on Github external
['hash-sum', 'hash']
]

const code
  = [
    ...modules.map(v => getImport(v, `./${v}`)),
    ...EXPORTED_MODULES.map(v => Array.isArray(v) ? getImport(v[1], v[0]) : getImport(v, v))
  ].join('\n')
  + `\n\nexport {\n`
  + [
    ...modules,
    ...EXPORTED_MODULES.map(v => Array.isArray(v) ? v[1] : v)
  ].map(v => `  ${v},`).join('\n')
  + '\n}'

fs.writeFileSync(target, code, 'utf-8')

console.log('[Success] Update entry file!')
github szwacz / fs-jetpack / spec / append.spec.ts View on Github external
const preparations = () => {
      fse.writeFileSync("file.bin", new Buffer([11]));
    };
github Nishkalkashyap / Quark-electron / scripts / create-release-notes.ts View on Github external
function updateReadme() {
    let file = fs.readFileSync('./README.md').toString();
    const regex = /```json[\w\W]+?```/;
    file = file.replace(regex, '```json\n' + JSON.stringify(json.dependencies, undefined, 4) + '\n```');
    fs.writeFileSync('./README.md', file);
}
github aws-amplify / amplify-cli / packages / graphql-relational-schema-transformer / src / RelationalDBResolverGenerator.ts View on Github external
}
    const reqFileName = `${queryTypeName}.${fieldName}.req.vtl`;
    const resFileName = `${queryTypeName}.${fieldName}.res.vtl`;

    const reqTemplate = print(
      compoundExpression([
        RelationalDBMappingTemplate.rdsQuery({
          statements: list([str(sql)]),
        }),
      ])
    );

    const resTemplate = print(ref('utils.toJson($utils.rds.toJsonObject($ctx.result)[0][0])'));

    fs.writeFileSync(`${this.resolverFilePath}/${reqFileName}`, reqTemplate, 'utf8');
    fs.writeFileSync(`${this.resolverFilePath}/${resFileName}`, resTemplate, 'utf8');

    let resolver = new AppSync.Resolver({
      ApiId: Fn.Ref(ResourceConstants.PARAMETERS.AppSyncApiId),
      DataSourceName: Fn.GetAtt(ResourceConstants.RESOURCES.RelationalDatabaseDataSource, 'Name'),
      FieldName: fieldName,
      TypeName: queryTypeName,
      RequestMappingTemplateS3Location: Fn.Sub(s3BaseUrl, {
        [ResourceConstants.PARAMETERS.S3DeploymentBucket]: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentBucket),
        [ResourceConstants.PARAMETERS.S3DeploymentRootKey]: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentRootKey),
        [resolverFileName]: reqFileName,
      }),
      ResponseMappingTemplateS3Location: Fn.Sub(s3BaseUrl, {
        [ResourceConstants.PARAMETERS.S3DeploymentBucket]: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentBucket),
        [ResourceConstants.PARAMETERS.S3DeploymentRootKey]: Fn.Ref(ResourceConstants.PARAMETERS.S3DeploymentRootKey),
        [resolverFileName]: resFileName,
      }),
github appcelerator / alloy / Alloy / commands / compile / index.js View on Github external
_.each(files, function(file) {
			var options = _.extend(_.clone(sourceMapper.OPTIONS_OUTPUT), {
					plugins: [
						[require('./ast/builtins-plugin'), compileConfig],
						[require('./ast/handle-alloy-globals')],
						[require('./ast/optimizer-plugin'), compileConfig.alloyConfig],
					]
				}),
				fullpath = path.join(compileConfig.dir.resources, file);

			logger.info('- ' + file);
			try {
				var result = babel.transformFileSync(fullpath, options);
				fs.writeFileSync(fullpath, result.code);
			} catch (e) {
				U.die('Error transforming JS file', e);
			}
		});
		lastFiles = _.union(lastFiles, files);