Tabnine Logo For Javascript
existsSync
Code IndexAdd Tabnine to your IDE (free)

How to use
existsSync
function
in
fs

Best JavaScript code snippets using fs.existsSync(Showing top 15 results out of 6,579)

origin: hua1995116/webchat

const mkdirsSync = function(dirname) {
 if (fs.existsSync(dirname)) {
   return true;
 }
 if (mkdirsSync(path.dirname(dirname))) {
   fs.mkdirSync(dirname);
   return true;
 }
}
origin: lando/lando

_(config.LANDO_METRICS_PLUGINS)
 .map(plugin => _.merge({}, plugin, {path: path.resolve(__dirname, 'plugins', `${plugin.name}.js`)}))
 .filter(plugin => fs.existsSync(plugin.path))
 .map(plugin => _.merge({}, plugin, {Reporter: require(plugin.path)}))
 .value()
origin: GoogleChromeLabs/ndb

forceFileLoad(fileNameURL) {
  const fileName = fileURLToPath(fileNameURL);
  if (fileName.startsWith(this._embedderPath) && fs.existsSync(fileName))
   this._client.filesChanged([{type: 'add', name: fileNameURL}]);
 }
origin: laurent22/joplin

// Resolve file paths in the same order as webpack
const resolveModule = (resolveFn, filePath) => {
  const extension = moduleFileExtensions.find(extension =>
    fs.existsSync(resolveFn(`${filePath}.${extension}`))
  );

  if (extension) {
    return resolveFn(`${filePath}.${extension}`);
  }

  return resolveFn(`${filePath}.js`);
}
origin: lando/lando

_(files)
 .flatMap(file => traverseUp(path.resolve(startFrom, file)))
 .sortBy().reverse()
 .filter(file => fs.existsSync(file) && path.isAbsolute(file))
 .thru(files => _.isEmpty(files) ? [] : [_.first(files)])
 .flatMap(dirFile => _.map(files, file => path.join(path.dirname(dirFile), file)))
 .filter(file => fs.existsSync(file))
 .value()
origin: lando/lando

// Helper for basic YAML
const getYaml = (dest, options, lando) => {
 // Get existing lando if we have it
 const existingLando = (fs.existsSync(dest)) ? lando.yaml.load(dest) : {};
 // Set the basics
 const landoConfig = {name: options.name, recipe: options.recipe};
 // Set the webroot if we have one
 if (!_.isEmpty(options.webroot)) _.set(landoConfig, 'config.webroot', options.webroot);
 // Return merged YAML
 return _.merge(existingLando, landoConfig);
}
origin: lando/lando

// Let's also make a copy of caCert with the standarized .crt ending for better linux compat
 // See: https://github.com/lando/lando/issues/1550
 lando.events.on('pre-engine-start', 3, data => {
  const caNormalizedCert = path.join(caDir, `${caDomain}.crt`);
  if (fs.existsSync(caCert) && !fs.existsSync(caNormalizedCert)) {
   // @NOTE: we need to use pre node 8.x-isms because pld roles with node 7.9 currently
   fs.writeFileSync(caNormalizedCert, fs.readFileSync(caCert));
  }
 });
origin: lando/lando

_(fs.readdirSync(baseDir, {withFileTypes: true}))
  .filter(dirent => dirent.isDirectory())
  .map(dirent => dirent.name)
  .concat('.')
  .map(directory => path.resolve(baseDir, directory, '.platform.app.yaml'))
  .filter(file => fs.existsSync(file))
  .map(file => ({data: yamlPlatform.load(fs.readFileSync(file)), file}))
  .map(data => ({name: data.data.name, file: data.file, dir: path.dirname(data.file)}))
  .value()
origin: lando/lando

constructor(id, config = {}) {
  // Move our config into the userconfroot if we have some
  // NOTE: we need to do this because on macOS and Windows not all host files
  // are shared into the docker vm

  if (fs.existsSync(config.confSrc)) utils.moveConfig(config.confSrc, config.confDest);
  this.id = id;
  this.config = {
   proxy: config.proxy,
   services: config.services,
   tooling: config.tooling,
  };
 }
origin: luangjokaj/wordpressify

function copyThemeDev() {
  if (!fs.existsSync('./build')) {
    log(buildNotFound);
    process.exit(1);
  } else {
    return src('./src/theme/**').pipe(dest('./build/wordpress/wp-content/themes/' + themeName));
  }
}
origin: lando/lando

_(files)
 // Filter if file exists
 .filter(fs.existsSync)
 // Start collecting
 .reduce((a, file) => exports.merge(a, yaml.safeLoad(fs.readFileSync(file))), {})
origin: lando/lando

// Helper to get init config
const getInitConfig = dirs => _(dirs)
 .filter(dir => fs.existsSync(dir))
 .flatMap(dir => glob.sync(path.join(dir, '*', 'init.js')))
 .map(file => require(file))
 .value()
origin: lando/lando

/*
  * Toggle the secret toggle
  */
 clearTaskCaches() {
  if (fs.existsSync(process.landoTaskCacheFile)) fs.unlinkSync(process.landoTaskCacheFile);
  if (fs.existsSync(process.landoAppTaskCacheFile)) fs.unlinkSync(process.landoAppTaskCacheFile);
 }
origin: luangjokaj/wordpressify

async function copyConfig() {
  if (await fs.existsSync('./wp-config.php')) {
    return src('./wp-config.php')
      .pipe(inject.after("define( 'DB_COLLATE', '' );", "\ndefine( 'DISABLE_WP_CRON', true );"))
      .pipe(dest('./build/wordpress'));
  }
}
origin: cube-js/cube.js

// Resolve file paths in the same order as webpack
const resolveModule = (resolveFn, filePath) => {
 const extension = moduleFileExtensions.find(extension =>
  fs.existsSync(resolveFn(`${filePath}.${extension}`))
 );

 if (extension) {
  return resolveFn(`${filePath}.${extension}`);
 }

 return resolveFn(`${filePath}.js`);
}
fsexistsSync

JSDoc

Synchronously tests whether or not the given path exists by checking with the file system.

Most used fs functions

  • readFileSync
    Synchronously reads the entire contents of a file.
  • readFile
    Asynchronously reads the entire contents of a file.
  • readdirSync
    Synchronous readdir(3) - read a directory.
  • writeFile
    Asynchronously writes data to a file, replacing the file if it already exists.
  • writeFileSync
    Synchronously writes data to a file, replacing the file if it already exists.
  • createWriteStream,
  • Stats.isDirectory,
  • statSync,
  • mkdirSync,
  • unlinkSync,
  • unlink,
  • ReadStream.pipe,
  • readdir,
  • Stats.isFile,
  • WriteStream.on,
  • stat,
  • ReadStream.on,
  • Stats.size

Popular in JavaScript

  • chalk
    Terminal string styling done right
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • qs
    A querystring parser that supports nesting and arrays, with a depth limit
  • minimist
    parse argument options
  • js-yaml
    YAML 1.2 parser and serializer
  • moment
    Parse, validate, manipulate, and display dates
  • webpack
    Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  • fs
  • q
    A library for promises (CommonJS/Promises/A,B,D)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now