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

How to use fs

Best JavaScript code snippets using fs(Showing top 15 results out of 20,178)

origin: GoogleChromeLabs/ndb

beforeAll(async function(state) {
  const DEVTOOLS_DIR = path.dirname(
    require.resolve('chrome-devtools-frontend/front_end/shell.json'));
  const frontendFolder = await fsMkdtemp(path.join(os.tmpdir(), 'ndb-test-frontend-'));
  await new ReleaseBuilder([
   path.join(__dirname, '..', 'front_end'),
   DEVTOOLS_DIR,
   path.join(__dirname, '..'),
   path.join(__dirname, '..', '..', '..')
  ], frontendFolder).buildApp('integration_test_runner');
  state.frontendFolder = frontendFolder;
 });
origin: hua1995116/webchat

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

fs.readdirSync(keyboardsDir).forEach(kb => {
    if (!kb.endsWith(".json")) return;
    kb = kb.replace(".json", "");
    if (kb === window.settings.keyboard) return;
    keyboards += `<option>${kb}</option>`;
  });
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: lando/lando

// Start listening
Promise.fromNode(cb => {
 api.listen(config.LANDO_API_PORT, cb);
})
// Load our routes
.then(() => {
 fs.readdirSync(path.join(__dirname, 'routes')).map(file => {
  require(`./routes/${file}`)(api, handler, {config, slack});
  log.info('Loaded route %s', file);
 });
 log.info('Listening on port: %s', config.LANDO_API_PORT);
});
origin: Sly777/ran

fs.readFile(tempPath, 'utf-8', (err, source) => {
  if (err) throw err;
  const template = handlebars.compile(source);
  const exportCode = template(data);

  callback(exportCode);
 });
origin: tulios/kafkajs

const sslConnectionOpts = () =>
 Object.assign(connectionOpts(), {
  port: 9093,
  ssl: {
   servername: 'localhost',
   rejectUnauthorized: false,
   ca: [fs.readFileSync('./testHelpers/certs/cert-signed', 'utf-8')],
  },
 })
origin: DavidAnson/markdownlint

tape("styleFiles", (test) => {
 test.plan(4);
 fs.readdir("./style", function readdir(err, files) {
  test.ifError(err);
  files.forEach(function forFile(file) {
   test.ok(require(path.join("../style", file)), "Unable to load/parse.");
  });
  test.end();
 });
});
origin: GoogleChromeLabs/ndb

/**
  * @param {string} fileURL
  * @param {string} encoding
  */
 readFile(fileURL, encoding) {
  return fs.readFileSync(new URL(fileURL), encoding);
 }
origin: Flood-UI/flood

const readFile = filePath => {
 return new Promise((resolve, reject) => {
  fs.readFile(filePath, 'utf8', (error, fileContent) => {
   if (error != null) {
    reject(error);
    return;
   }

   resolve(fileContent);
  });
 });
}
origin: nodejs/nodejs.org

function renderPost (results) {
 const templateStr = fs.readFileSync(path.resolve(__dirname, 'release.hbs')).toString('utf8')
 const template = Handlebars.compile(templateStr, { noEscape: true })
 const view = Object.assign({
  date: new Date().toISOString(),
  versionSlug: slugify(results.version)
 }, results)

 return Object.assign({
  content: template(view)
 }, results)
}
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

/*
  * Toggle the secret toggle
  */
 clearTaskCaches() {
  if (fs.existsSync(process.landoTaskCacheFile)) fs.unlinkSync(process.landoTaskCacheFile);
  if (fs.existsSync(process.landoAppTaskCacheFile)) fs.unlinkSync(process.landoAppTaskCacheFile);
 }
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: Flood-UI/flood

const writeFile = (filePath, fileContent) => {
 return new Promise((resolve, reject) => {
  fs.writeFile(filePath, fileContent, writeFileError => {
   if (writeFileError) {
    reject(writeFileError);
    return;
   }

   resolve(filePath);
  });
 });
}
fs

Most used fs functions

  • readFileSync
    Synchronously reads the entire contents of a file.
  • existsSync
    Synchronously tests whether or not the given path exists by checking with the file system.
  • 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.
  • createReadStream,
  • createWriteStream,
  • Stats.isDirectory,
  • statSync,
  • mkdirSync,
  • unlinkSync,
  • unlink,
  • ReadStream.pipe,
  • readdir,
  • Stats.isFile,
  • WriteStream.on,
  • stat,
  • ReadStream.on,
  • Stats.size

Popular in JavaScript

  • superagent
    elegant & feature rich browser / node HTTP with a fluent API
  • http
  • crypto
  • axios
    Promise based HTTP client for the browser and node.js
  • path
  • rimraf
    A deep deletion module for node (like `rm -rf`)
  • 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.
  • handlebars
    Handlebars provides the power necessary to let you build semantic templates effectively with no frustration
  • lodash
    Lodash modular utilities.
  • 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