How to use the fs-extra.statSync 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 jolaleye / snap / tasks / show.js View on Github external
function walk(currentPath, level) {
  // give the current item a name & level
  const item = { name: path.basename(currentPath), level };
  // get its stats
  const stats = fs.statSync(currentPath);
  // look at the item's contents if it has any
  if (stats.isDirectory()) {
    item.children = fs.readdirSync(currentPath).map(child => walk(path.join(currentPath, child), level + 1));
  }
  return item;
}
github oskariorg / oskari-frontend / webpack / sprite.js View on Github external
try {
        stats = fs.statSync(cfg.baseIconsDir);
    } catch (e) {
        failWarn('Default icons directory (' + cfg.baseIconsDir + ') was NOT found. Please provide a proper baseIconsDir!');
        return;
    }
    if (stats && !stats.isDirectory()) {
        failWarn('Default icons directory (' + cfg.baseIconsDir + ') is NOT a directory. Please provide a proper baseIconsDir!');
    }
    // check application overrides
    if (!cfg.appIconsDir) {
        // no override
        return;
    }
    try {
        appOverrideDirStats = fs.statSync(cfg.appIconsDir);
    } catch (e) {
        // doesn't exist -> act as not given
        failWarn('Application icons override directory (' + cfg.appIconsDir + ') was NOT found. Please provide a proper appIconsDir!');
    }
    if (!appOverrideDirStats) {
        // no app overrides
        return;
    }
    if (appOverrideDirStats && !appOverrideDirStats.isDirectory()) {
        failWarn('Application icons override directory (' + cfg.appIconsDir + ') is NOT a directory. Please provide a proper appIconsDir!');
    }
}
github expo / expo-cli / packages / xdl / src / UserSettings.ts View on Github external
function userSettingsFile(): string {
  let dir = dotExpoHomeDirectory();
  let file = path.join(dir, SETTINGS_FILE_NAME);
  try {
    // move exponent.json to state.json
    let oldFile = path.join(dir, 'exponent.json');
    if (fs.statSync(oldFile).isFile()) {
      fs.renameSync(oldFile, file);
    }
  } catch (e) {
    // no old directory, continue
  }
  return file;
}
github mozilla-jetpack / jpm / test / utils / index.js View on Github external
function isDir(filePath) {
  return fs.statSync(filePath).isDirectory();
}
exports.isDir = isDir;
github hexparrot / mineos-node / test / test-mineos.js View on Github external
function(callback) {
      test.equal(fs.statSync(instance.env.cwd).uid, OWNER_CREDS['uid']);
      test.equal(fs.statSync(instance.env.bwd).uid, OWNER_CREDS['uid']);
      test.equal(fs.statSync(instance.env.awd).uid, OWNER_CREDS['uid']);
      test.equal(fs.statSync(instance.env.sp).uid, OWNER_CREDS['uid']);
      test.equal(fs.statSync(instance.env.sc).uid, OWNER_CREDS['uid']);
      test.equal(fs.statSync(instance.env.cc).uid, OWNER_CREDS['uid']);

      test.equal(fs.statSync(instance.env.cwd).gid, OWNER_CREDS['gid']);
      test.equal(fs.statSync(instance.env.bwd).gid, OWNER_CREDS['gid']);
      test.equal(fs.statSync(instance.env.awd).gid, OWNER_CREDS['gid']);
      test.equal(fs.statSync(instance.env.sp).gid, OWNER_CREDS['gid']);
      test.equal(fs.statSync(instance.env.sc).gid, OWNER_CREDS['gid']);
      test.equal(fs.statSync(instance.env.cc).gid, OWNER_CREDS['gid']);

      test.equal(oct2dec(fs.statSync(instance.env.sp).mode), 664);
      test.equal(oct2dec(fs.statSync(instance.env.sc).mode), 664);
      test.equal(oct2dec(fs.statSync(instance.env.cc).mode), 664);

      test.equal(mineos.server_list(BASE_DIR)[0], server_name);
github ZencashOfficial / arizen / app / main.js View on Github external
function pruneSplit(files, rule, n) {
        let last = null;
        let keep = [];
        if (!n) {
            return keep;
        }
        for (let f of files) {
            let stats = fs.statSync(backupDir + "/" + f);
            let period = DateTime
                .fromJSDate(stats.mtime)
                .toFormat(PRUNING_PATTERNS_DICT[rule]);
            if (period !== last) {
                last = period;
                keep.push(f);
                if (keep.length === n){
                    break;
                }
            }
        }
        return keep;
    }
github alienfast / gulp-pipeline / dist / gulp-pipeline.es.js View on Github external
isDir(...args) {
    let filepath = path.join(...args)
    return this.exists(filepath) && fs.statSync(filepath).isDirectory()
  }
github oracle / generator-oraclejet / util / index.js View on Github external
return fs.readdirSync(source).filter(file =>
      fs.statSync(path.join(source, file)).isDirectory());
  },
github jzimmek / serverless-plugin-node-shim / index.js View on Github external
files.forEach(file => {
            const fullPath = path.join(nodeShimDir, file),
              stat = fs.statSync(fullPath);

            if (!stat.isFile()) return;

            let idx = handlerFiles.indexOf(file);

            if (idx !== -1) {
              const shimFullPath = fullPath,
                shimmedFullPath = shimFullPath.replace(/\.js$/, "-shimmed.js"),
                shimCode = fs.readFileSync(shimFullPath).toString(),
                functionObject = functionObjects[idx];

              zip.append(
                shimCode
                  .replace(
                    /EXEC_PATH/g,
                    this.serverless.service.custom.nodeShim.execPath
github Kode / khamake / src / HaxeProject.ts View on Github external
}
	else {
		otheroptions.push({
			n: 'option',
			testMovie: 'Default'
		});
	}

	let def = '';
	for (let d of options.defines) {
		def += '-D ' + d + '
';
	}
	if (options.language === 'java' && fs.existsSync(options.haxeDirectory) && fs.statSync(options.haxeDirectory).isDirectory() && fs.existsSync(path.join(options.haxeDirectory, 'hxjava', 'hxjava-std.jar'))) {
		def += '-java-lib ' + path.relative(projectdir, path.join(options.haxeDirectory, 'hxjava', 'hxjava-std.jar')) + '
';
	}
	if (options.language === 'cs' && fs.existsSync(options.haxeDirectory) && fs.statSync(options.haxeDirectory).isDirectory() && fs.existsSync(path.join(options.haxeDirectory, 'netlib'))) {
		def += '-net-std ' + path.relative(projectdir, path.join(options.haxeDirectory, 'netlib')) + '
';
	}
	def += '-D kha_output="' + path.resolve(path.join(projectdir, options.to)) + '"
';
	for (let param of options.parameters) {
		def += escapeXml(param) + '
';
	}

	let project = {
		n: 'project',
		version: '2',
		e: [
			'Output SWF options',
			output,
			'Other classes to be compiled into your SWF',
			{
				n: 'classpaths',