How to use write - 10 common examples

To help you get started, we’ve selected a few write 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 royriojas / file-entry-cache / test / specs / cache.js View on Github external
it( 'should return fileDescriptor for all the passed files', function () {
      cache = fileEntryCache.create( 'testCache' );

      var files = expand( path.resolve( __dirname, '../fixtures/*.txt' ) );
      var oFiles = cache.normalizeEntries( files );

      cache.reconcile();

      // modify a file
      write( path.resolve( fixturesDir, fixtureFiles[ 2 ].name ), fixtureFiles[ 2 ].content + 'modified!!!' );

      oFiles = cache.normalizeEntries( files );

      expect( oFiles.length ).to.equal( 4 );

      var changedFile = oFiles.filter( function ( entry ) {
        return entry.changed;
      } );

      expect( changedFile[ 0 ].key ).to.contains( fixtureFiles[ 2 ].name );
    } );
github lint-deps / lint-deps / lib / install.js View on Github external
.catch(err => {
      // if installation failed, ensure that package.json is not modified
      if (err.code !== 0) {
        write.sync(app.pkg.path, pkgBuffer);
        console.log(err);
        process.exit(err.code);
      }

      err.installer = app.installer;
      throw err;
    });
};
github scriptPilot / app-framework / scripts.old / webpack.prod.conf.js View on Github external
new OnBuildPlugin(function (stats) {
      // Save manifest file
      write.sync(path.resolve(cfg.appRoot, 'www/build-' + app.version, 'manifest.json'), JSON.stringify(manifest))

      // Save browserconfig file
      let xml = '' +
                '' +
                  '' +
                    '' +
                      '' +
                      '#da532c' +
                    '' +
                  '' +
                ''
      write.sync(path.resolve(cfg.appRoot, 'www/build-' + app.version, 'browserconfig.xml'), xml)

      // Copy icon files (see http://realfavicongenerator.net/faq for details)
      copy(path.resolve(cfg.packageRoot, 'icons/favicon-*'), path.resolve(cfg.appRoot, 'www/build-' + app.version))
      copy(path.resolve(cfg.packageRoot, 'icons/android-chrome-*'), path.resolve(cfg.appRoot, 'www/build-' + app.version))
      copy(path.resolve(cfg.packageRoot, 'icons/mstile-*'), path.resolve(cfg.appRoot, 'www/build-' + app.version))
      copy(path.resolve(cfg.packageRoot, 'icons/apple-touch-icon-*'), path.resolve(cfg.appRoot, 'www/build-' + app.version))

      // Rename Apple touch icon
      rename(path.resolve(cfg.appRoot, 'www/build-' + app.version, 'apple-touch-icon-180x180.png'), path.resolve(cfg.appRoot, 'www/build-' + app.version, 'apple-touch-icon.png'))

      // Compress images
      let images = list(path.resolve(cfg.appRoot, 'www/build-' + app.version + '/img'))
      for (let i = 0; i < images.length; i++) {
        console.log('Compress ' + images[i])
      }
github breakdance / breakdance / test / support / generate.js View on Github external
$('h2,table').each(function(i, ele) {
  if (ele.name === 'h2') {
    stack.push('mozilla-html-' + dashcase($(this).text().trim()) + '');
  } else {
    var name = stack.pop();
    var expected = cwd('../expected', name + '.md');
    var fixture = cwd('../fixtures', name + '.html');
    var html = $.html(this);
    write.sync(fixture, html);
    write.sync(expected, breakdance(html));
    console.log('wrote:', name);
  }
});
github jonschlinkert / tokenize-comment / test / support / index.js View on Github external
var fixtures = exports.files(__dirname, '../fixtures');
  var comments = extract(fixtures[name]).filter(function(comment) {
    return comment.type === 'BlockComment';
  });

  var res = '';

  for (var i = 0; i < comments.length; i++) {
    var raw = '\n\n/*' + comments[i].raw + '*/\n';
    var tok = stringify(tokenize(raw), {indent: '  '});
    tok = tok.replace(/\s*Node\s*/g, '');
    res += raw;
    res += `\nassert.deepEqual(tokenize(comments[${i}].raw), ${tok});`;
  }

  writeFile.sync(dest, res.trim());
};
github jonschlinkert / kind-of / benchmark / index.js View on Github external
.then(function(stats) {
    write.sync(path.join(__dirname, 'stats.json'), JSON.stringify(stats, null, 2))
    write.sync(path.join(__dirname, 'stats.md'), suite.render(stats));
  })
  .catch(console.error);
github micromatch / micromatch / benchmark / index.js View on Github external
.then(function(stats) {
    write.sync(path.join(__dirname, 'stats.json'), JSON.stringify(stats, null, 2))
    write.sync(path.join(__dirname, 'stats.md'), suite.render(stats));
  })
  .catch(console.error);
github jhanstra / snipster / commands / init / sync.js View on Github external
if (editor == 'atom') {
        languageExtension = getExtensionFromAtomLanguageScope(languageScope)
      } else if (editor == 'vscode') {
        languageExtension = getExtensionFromVSCodeLanguageScope(languageScope)
      } else if (editor == 'sublime') {
        languageExtension = getExtensionFromSublimeLanguageScope(languageScope)
      }
      for (let snippet in preSnipsterMap[languageScope]) {
        let filename = preSnipsterMap[languageScope][snippet].prefix + '.' + languageExtension
        snippetFilesSynced.push(filename)
        try {
          if (editor == 'vscode') {
            let body = preSnipsterMap[languageScope][snippet].body.join('\n')
            write.sync(userDirectory + '/' + editor + '/' + filename, body)
          } else {
            write.sync(userDirectory + '/' + editor + '/' + filename, preSnipsterMap[languageScope][snippet].body)
          }
        } catch(e) {
          if (e) { console.log(chalk.red(e))}
        }
      }
    }
  }
  return snippetFilesSynced
}
github jonschlinkert / gray-matter / benchmark / index.js View on Github external
.then(function(stats) {
    write.sync(dir('stats.json'), JSON.stringify(stats, null, 2));
    write.sync(dir('stats.md'), suite.render(stats));
  })
  .catch(console.error);
github royriojas / flat-cache / utils.js View on Github external
writeJSON: function ( filePath, data ) {
    write.sync( filePath, flatted.stringify( data ) );
  }
};

write

Write data to a file, replacing the file if it already exists and creating any intermediate directories if they don't already exist. Thin wrapper around node's native fs methods.

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis

Popular write functions