How to use the hexo-fs.readFile function in hexo-fs

To help you get started, we’ve selected a few hexo-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 hexojs / hexo-deployer-git / test / deployer.js View on Github external
return spawn('git', ['clone', fakeRemote, validateDir, '--branch', branch]).then(() => {
      // Check the branch name
      return fs.readFile(pathFn.join(validateDir, '.git', 'HEAD'));
    }).then(content => {
      content.trim().should.eql('ref: refs/heads/' + branch);
github Tencent / feflow / lib / internal / generator / generator.js View on Github external
}).map(function (name) {
      let path = pathFn.join(pluginDir, name);
      let packagePath = pathFn.join(path, 'package.json');

      // Read generator config.
      return fs.readFile(packagePath).then(function (content) {
        const json = JSON.parse(content);
        const desc = json.description;

        return {name, desc};
      });
    });
  }
github cypress-io / cypress / docs / lib / url_generator.js View on Github external
function getLocalFile (sidebar, href, source) {
  // get the resolve path to the file
  // cypress-101 -> guides/core-concepts/cypress-101.html
  const pathToFile = findFileBySource(sidebar, href)

  if (pathToFile) {
    // ensure this physically exists on disk
    // inside of './source' folder
    return fs.readFile(
      path.resolve('source', pathToFile.replace('.html', '.md'))
    ).then((str) => {
      // return an array with
      // path to file, and str bytes
      return [pathToFile, str]
    })
  }

  return Promise.reject(
    new Error(`Constructing {% url %} tag helper failed

    > The source file was: ${source}

    > Could not find a valid doc file in the sidebar.yml for: ${href}
    `)
  )
github hexojs / hexo / test / scripts / console / deploy.js View on Github external
  it('generate', () => fs.writeFile(pathFn.join(hexo.source_dir, 'test.txt'), 'test').then(() => deploy({generate: true})).then(() => fs.readFile(pathFn.join(hexo.public_dir, 'test.txt'))).then(content => {
    content.should.eql('test');
github hexojs / hexo / test / scripts / console / init.js View on Github external
return Promise.map(assets, function(item){
      return Promise.all([
        fs.readFile(pathFn.join(assetDir, item === '.gitignore' ? 'gitignore' : item)),
        fs.readFile(pathFn.join(baseDir, item))
      ]).spread(function(asset, target){
        target.should.eql(asset);
      });
    }).then(function(){
      return fs.rmdir(baseDir);
github hexojs / hexo / test / scripts / hexo / post.js View on Github external
}).then(post => {
      post.path.should.eql(path);
      post.content.should.eql(content);
      hexo.config.filename_case = 0;

      return fs.readFile(path);
    }).then(data => {
      data.should.eql(content);
github hexojs / hexo-deployer-git / test / deployer.js View on Github external
}).then(() => {
        const extTxtFile = pathFn.join(validateDir, extendDirName, 'ext.txt');

        return fs.readFile(extTxtFile);
      }).then(content => {
        content.should.eql('ext');
github hexojs / hexo / test / scripts / console / new.js View on Github external
    }).then(() => fs.readFile(path)).then(content => {
      content.should.eql(body);
github hexojs / hexo / lib / cli / find_pkg.js View on Github external
function checkPkg(path){
  return fs.readFile(path).then(function(content){
    var json = JSON.parse(content);
    return typeof json.hexo === 'object';
  });
}
github hexojs / hexo / lib / hexo / render.js View on Github external
return new Promise((resolve, reject) => {
    if (!data) return reject(new TypeError('No input file or string!'));
    if (data.text != null) return resolve(data.text);
    if (!data.path) return reject(new TypeError('No input file or string!'));

    fs.readFile(data.path).then(resolve, reject);
  }).then(text => {
    data.text = text;