How to use the hexo-fs.statSync 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 mimming / snippets / hexo-sheets-plugin / blog / scripts / hexo-posts-from-csv.js View on Github external
entry.should.have.property('imageurl');
      entry.should.have.property('slug');
      entry.should.not.have.property('localimage');

      // TODO: deal with urls that do not parse
      const imageUrl = url.parse(entry.imageurl);
      const imageFilename = imageUrl.pathname.split('/').pop();

      // TODO: figure out if this is the safest way to construct local image paths
      // Construct the local image path
      const localPath = `${hexo.config.source_dir}/images/${entry.slug}_${imageFilename}`;
      const relativeUrl = `/images/${entry.slug}_${imageFilename}`;

      // stat each image as a jpg, then as png, see if it exists
      try {
        fs.statSync(localPath);
        // if exists, add localimage to entry
        entry['localimage'] = relativeUrl;
      } catch (error) {
        // Do nothing!  Pass the entry through
      }
    });
    resolve(entries);
github hexojs / hexo / test / scripts / box / file.js View on Github external
file.stat((err, fileStats) => {
      if (err) return callback(err);

      fileStats.should.eql(fs.statSync(file.source));
      callback();
    });
  });
github 75k / hexo-deployer-cos-enhanced / lib / main.js View on Github external
return new Promise((resolve, reject) => {
        cos.putObject({
            Bucket: config.bucket,
            Region: config.region,
            Key: file,
            Body: fs.createReadStream(filePath),
            ContentLength: fs.statSync(filePath).size,
            onProgress: function (progressData) {
                //console.log(JSON.stringify(progressData));
            },
        }, (err, data) => {
            if (err) {
                reject(err);
            } else {
                resolve(data);
            }
        })
    })
}
github yedaodao / hexo-deployer-aliyun / lib / deployer.js View on Github external
files.forEach(function (filePath) {
        var absPath = pathFn.join(dir, filePath),
            stat = fs.statSync(absPath);
        if (stat.isDirectory()) {
            traverseFiles(absPath, handle);
        } else {
            handle(absPath);
        }
    });
}
github zhuzhuyule / HexoEditor / views / main / hexo / loadconfig.js View on Github external
function loadYAMLFile(file) {
    if (!file) return loadsh.extend({}, defConfig);
    file = file.toString().replace(/\\+/g, '\\\\');
    if (!fs.existsSync(file)) return {};
    var configPath = file;
    if (fs.statSync(file).isDirectory()) {
        configPath = (path.join(file, '_config.yml'));
    }
    var baseDir = path.dirname(configPath);
    var config = fs.existsSync(configPath) ? YAML.parse(fs.readFileSync(configPath).toString()) : {};
    defConfig.__basedir = baseDir;
    var themeConfig = {};
    if (config.theme) {
        defConfig.__themedir = path.join( baseDir,'themes',config.theme);
        configPath = path.join( defConfig.__themedir,'_config.yml');
        themeConfig = fs.existsSync(configPath) ? YAML.parse(fs.readFileSync(configPath).toString()) : {};
    }
    return loadsh.extend({}, defConfig, config, themeConfig);
}
github Tencent / feflow / lib / core / initClient.js View on Github external
return new Promise(function (resolve) {
      if (fs.existsSync(baseDir) && fs.statSync(baseDir).isFile()) {
        fs.unlinkSync(baseDir);
      }

      if (!fs.existsSync(baseDir)) {
        log.info('检测到这是您第一次使用feflow,即将进行cli client初始化');

        fs.ensurePathSync(baseDir);
      }

      log.debug('.feflow 目录已经创建');
      resolve(ctx);
    });
  }
github hexojs / hexo / lib / box / file.js View on Github external
File.prototype.statSync = function(options) {
  return statSync(this.source);
};
github EYHN / hexo-helper-live2d / lib / listFiles.js View on Github external
module.exports = function listFiles (dirPath) {

  const lsDir = fs.readdirSync(dirPath);
  const filesArr = [];
  for (const fileName of lsDir) {

    const pathName = path.join(dirPath, fileName);
    if (fs.statSync(pathName).isDirectory()) {

      filesArr.push(...listFiles(pathName));

    } else {

      filesArr.push(pathName);

    }

  }
  return filesArr;

};