How to use co-fs - 10 common examples

To help you get started, we’ve selected a few co-fs 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 duojs / duo / test / api.js View on Github external
it('should not generate any sourcemaps', function* () {
        var duo = build('simple');
        yield duo.write();
        var src = yield fs.readFile(path('simple', 'build/index.js'), 'utf8');
        assert(exists('simple/build/index.js'));
        assert.equal(src.indexOf('//# sourceMappingURL='), -1); // inline
        assert(!exists('simple/build/index.js.map'));           // external
      });
    });
github askmike / gekko / web / routes / strategies.js View on Github external
module.exports = function *() {
  const strategyDir = yield fs.readdir(gekkoRoot + 'strategies');
  const strats = strategyDir
    .filter(f => _.last(f, 3).join('') === '.js')
    .map(f => {
      return { name: f.slice(0, -3) }
    });

  // for every strat, check if there is a config file and add it
  const stratConfigPath = gekkoRoot + 'config/strategies';
  const strategyParamsDir = yield fs.readdir(stratConfigPath);

  for(let i = 0; i < strats.length; i++) {
    let strat = strats[i];
    if(strategyParamsDir.indexOf(strat.name + '.toml') !== -1)
      strat.params = yield fs.readFile(stratConfigPath + '/' + strat.name + '.toml', 'utf8')
    else
      strat.params = '';
  }

  this.body = strats;
}
github duojs / duo / test / api.js View on Github external
it('should rebuild correctly when a file is touched', function* () {
      var p = join(path('rebuild'), 'index.js');
      var js = yield fs.readFile(p, 'utf8');
      var a = build('rebuild');
      var b = build('rebuild');
      var c = build('rebuild');
      a = yield a.run();
      fs.writeFile(p, js);
      b = yield b.run();
      c = yield c.run();
      assert(a.code && b.code && c.code);
      assert.equal(a.code, b.code);
      assert.equal(b.code, c.code);
    });
github duojs / duo / test / cli.js View on Github external
it('should include inline source-maps', function* () {
      var out = yield exec('--development index.js', 'simple');
      if (out.error) throw out.error;
      var entry = yield fs.readFile(path('simple/build/index.js'), 'utf8');
      var map = convert.fromSource(entry).toObject();
      var src = map.sourcesContent[map.sources.indexOf('/two.js')];
      assert.equal(src.trim(), 'module.exports = \'two\';');
    });
  });
github duojs / duo / test / cli.js View on Github external
function* build(fixture) {
  fixture += extname(fixture) ? '' : '/build.js';
  var file = path(fixture);
  var js = yield fs.readFile(file, 'utf-8');
  return evaluate(js);
}
github apebook / apebook / base / book.js View on Github external
chapterCount: function*() {
    var src = this.bookPath();
    var url = src + '/' + 'SUMMARY.md';
    var exist = yield fs.exists(url);
    if (!exist) return 0;
    var content = yield fs.readFile(url);
    content = content.toString();
    return content.split('*').length - 1;
  },
  //渲染md文件成html
github dominicbarnes / koa-handlebars / lib / renderer.js View on Github external
Renderer.prototype.getFile = function *(file) {
  debug("reading file %s", chalk.grey(path.relative(this.options.root, file)));
  return fm(yield fs.readFile(file, "utf8"));
};
github efeiefei / node-file-manager / lib / fileManager.js View on Github external
function* addFile(file) {
    var data = yield fs.readFile(file);
    var name;
    if (embedDirs) {
      name = file;
      if (name.indexOf(dirPath) === 0) {
        name = name.substring(dirPath.length);
      }
    } else {
      name = path.basename(file);
    }
    zip.file(name, data);
    C.logger.info('Added ' + name + ' ' + data.length + ' bytes to archive ' + archive);
  }

co-fs

fs wrappers for 'co'

MIT
Latest version published 11 years ago

Package Health Score

48 / 100
Full package analysis

Popular co-fs functions