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

How to use fs-extra

Best JavaScript code snippets using fs-extra(Showing top 15 results out of 5,634)

origin: cube-js/cube.js

async writeConfig(config) {
  const { cubeCloudConfigPath, configFile } = this.configFile();
  await fs.mkdirp(cubeCloudConfigPath);
  await fs.writeJson(configFile, config);
 }
origin: cube-js/cube.js

async persistSources(sourceContainer, packageVersions) {
  const sources = sourceContainer.outputSources();
  await Promise.all(sources.map((file) => fs.outputFile(path.join(this.appPath, file.fileName), file.content)));
  const packageJson = fs.readJsonSync(path.join(this.appPath, 'package.json'));
  packageJson.cubejsTemplates = {
   ...packageJson.cubejsTemplates,
   ...packageVersions,
  };
  await fs.writeJson(path.join(this.appPath, 'package.json'), packageJson, {
   spaces: 2,
  });
 }
origin: cube-js/cube.js

async downloadPackages() {
  await this.downloadRepo();

  await decompress(this.repoArchivePath, this.tmpFolderPath, {
   plugins: [decompressTargz()],
  });

  const dir = fs.readdirSync(this.tmpFolderPath).find((name) => !name.endsWith('tar.gz'));
  await executeCommand('npm', ['install'], { cwd: path.resolve(this.tmpFolderPath, dir) });

  return {
   packagesPath: path.join(this.tmpFolderPath, dir, 'packages'),
  };
 }
origin: cube-js/cube.js

function copyPublicFolder() {
 fs.copySync(paths.appPublic, paths.appBuild, {
  dereference: true,
  filter: file => file !== paths.appHtml,
 });
}
origin: GladysAssistant/Gladys

/**
  * @public
  * @description This function starts service
  * @example
  * gladys.services['rtsp-camera'].start();
  */
 async function start() {
  logger.log('starting RTSP service');
  // make sure the tempFolder exists
  await fse.ensureDir(gladys.config.tempFolder);
 }
origin: laurent22/joplin

main().catch((error) => {
  console.error(error);
  process.exit(1);
}).then(() => {
  return fs.remove(tempDir);
});
origin: standard-things/esm

function cleanJS() {
 for (const filename of jsPaths) {
  const content = fs.readFileSync(filename, "utf8")

  process.once("exit", () => fs.outputFileSync(filename, content))

  fs.outputFileSync(filename, minifyJS(content))
 }
}
origin: standard-things/esm

function setupNode() {
 const basePath = path.resolve(nodePath, isWin ? "" : "..")

 return trash(basePath)
  .then(() => fs.ensureLink(process.execPath, nodePath))
}
origin: cube-js/cube.js

fileHash(file) {
  return new Promise((resolve, reject) => {
   const hash = crypto.createHash('sha1');
   const stream = fs.createReadStream(file);
   stream.on('error', err => reject(err));
   stream.on('data', chunk => hash.update(chunk));
   stream.on('end', () => resolve(hash.digest('hex')));
  });
 }
origin: hua1995116/webchat

const rmDirFiles = dir => {
  const dirPath = fs.readdirSync(dir);
  dirPath.map(item => {
    const currentPath = path.join(dir, item);
    console.log(`rmove ${currentPath}`);
    fileTool.removeSync(currentPath);
  });
}
origin: standard-things/esm

fs.readFileSync(gitignorePath, "utf8")
 .split(/\r?\n/)
 .map((sourceLine) => {
  sourceLine = sourceLine.trim()

  if (sourceLine !== "") {
   return sourceLine.startsWith("/")
    ? sourceLine.slice(1)
    : "**/" + sourceLine
  }

  return sourceLine
 })
 .filter(Boolean)
origin: standard-things/esm

function copyBundle() {
 const srcPath = path.resolve(buildPath, "esm.js")

 return fs.existsSync(srcPath)
  ? fs.copy(srcPath, loaderPath)
  : Promise.resolve()
}
origin: Flood-UI/flood

const copyPublicFolder = () => {
 fs.copySync(paths.appPublic, paths.appBuild, {
  dereference: true,
  filter: file => file !== paths.appHtml,
 });
}
origin: laurent22/joplin

function copyPublicFolder() {
  fs.copySync(paths.appPublic, paths.appBuild, {
    dereference: true,
    filter: file => file !== paths.appHtml,
  });
}
origin: standard-things/esm

function cleanJS() {
 for (const filename of jsPaths) {
  const content = fs.readFileSync(filename, "utf8")

  process.once("exit", () => fs.outputFileSync(filename, content))

  fs.outputFileSync(filename, minifyJS(content))
 }
}
fs-extra(npm)

JSDoc

fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.

Most used fs-extra functions

  • copySync
  • emptyDirSync
  • readFileSync
  • remove
  • existsSync
  • removeSync,
  • writeFileSync,
  • writeFile,
  • ensureDirSync,
  • copy,
  • readdirSync,
  • statSync,
  • createWriteStream,
  • readdir,
  • ensureDir,
  • unlink,
  • stat,
  • mkdirSync,
  • createReadStream

Popular in JavaScript

  • semver
    The semantic version parser used by npm.
  • readable-stream
    Streams3, a user-land copy of the stream library from Node.js
  • colors
    get colors in your node.js console
  • debug
    small debugging utility
  • redis
    Redis client library
  • express
    Fast, unopinionated, minimalist web framework
  • mime-types
    The ultimate javascript content-type utility.
  • minimatch
    a glob matcher in javascript
  • fs
  • Top PhpStorm plugins
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