How to use the fs-extra.existsSync 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 IBM / watson-discovery-news-alerting / app / scripts / build.js View on Github external
require('../config/env');

const path = require('path');
const chalk = require('chalk');
const fs = require('fs-extra');
const webpack = require('webpack');
const config = require('../config/webpack.config.prod');
const paths = require('../config/paths');
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');

const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild;
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
const useYarn = fs.existsSync(paths.yarnLockFile);

// Warn and crash if required files are missing
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
  process.exit(1);
}

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

// Create the production build and print the deployment instructions.
function build(previousFileSizes) {
  console.log('Creating an optimized production build...');
github webiny / webiny-js / packages / cli / create / index.js View on Github external
module.exports = async ({ name, tag }) => {
    const root = join(process.cwd(), name);

    if (fs.existsSync(root)) {
        console.log(
            `🚨 Aborting: destination folder ${green(
                name
            )} already exists! Please enter a different folder name.`
        );
        process.exit(1);
    }

    console.log(`📦 Creating a new Webiny project in ${green(root)}...`);
    fs.ensureDirSync(root);
    process.chdir(root);

    fs.ensureDirSync("apps");
    fs.ensureDirSync("packages");

    // Copy project files
github richardfrost / AdvancedProfanityFilter / bin / package-extension.js View on Github external
function buildEdge(manifest, zip) {
  if (!fse.existsSync('./store/edge')) { return false; }
  console.log('Building ./extension-edge.zip');
  let msPreload = {
    backgroundScript: "backgroundScriptsAPIBridge.js",
    contentScript: "contentScriptsAPIBridge.js"
  }

  // Fix options_page
  manifest.options_page = manifest.options_ui.page;
  delete manifest.options_ui;

  // Add ms-proload polyfills
  manifest['-ms-preload'] = msPreload;
  updateManifestFileInZip(zip, manifest);
  zip.addLocalFile('./store/edge/src/backgroundScriptsAPIBridge.js', null);
  zip.addLocalFile('./store/edge/src/contentScriptsAPIBridge.js', null);
  fse.removeSync('./extension-edge.zip');
github ngrx / platform / projects / ngrx.io / tools / examples / example-boilerplate.js View on Github external
exampleFolders.forEach(exampleFolder => {
      const exampleConfig = this.loadJsonFile(path.resolve(exampleFolder, EXAMPLE_CONFIG_FILENAME));

      if (!fs.existsSync(SHARED_NODE_MODULES_PATH)) {
        throw new Error(`The shared node_modules folder for the examples (${SHARED_NODE_MODULES_PATH}) is missing.\n` +
        `Perhaps you need to run "yarn example-use-npm" or "yarn example-use-local" to install the dependencies?`);
      }

      // Link the node modules - requires admin access (on Windows) because it adds symlinks
      const destinationNodeModules = path.resolve(exampleFolder, 'node_modules');
      fs.ensureSymlinkSync(SHARED_NODE_MODULES_PATH, destinationNodeModules);

      const boilerPlateType = exampleConfig.projectType || 'cli';
      const boilerPlateBasePath = path.resolve(BOILERPLATE_BASE_PATH, boilerPlateType);

      // Copy the boilerplate specific files
      BOILERPLATE_PATHS[boilerPlateType].forEach(filePath => this.copyFile(boilerPlateBasePath, exampleFolder, filePath));

      // Copy the boilerplate common files
      BOILERPLATE_PATHS.common.forEach(filePath => this.copyFile(BOILERPLATE_COMMON_BASE_PATH, exampleFolder, filePath));
github hyperledger / fabric-sdk-node / test / unit / headless-tests.js View on Github external
pipe.on('close', function() {
			var checkPath = path.join(destDir, 'src', 'github.com', 'example_cc');
			t.equal(fs.existsSync(checkPath), true, 'The tar.gz file produced by Chain.packageChaincode() has the "src/github.com/example_cc" folder');
		});
	});
github peeriodproject / core / test / utils / testUtils.js View on Github external
function deleteFolderRecursive(path) {
        if (fs.existsSync(path)) {
            fs.readdirSync(path).forEach(function (file, index) {
                var curPath = path + '/' + file;
                if (fs.lstatSync(curPath).isDirectory()) {
                    testUtils.deleteFolderRecursive(curPath);
                } else {
                    fs.unlinkSync(curPath);
                }
            });

            fs.rmdirSync(path);
        }
    }
    testUtils.deleteFolderRecursive = deleteFolderRecursive;
github ArkEcosystem / core / packages / core-webhooks / src / database.ts View on Github external
public make(): void {
        const adapterFile: string = `${process.env.CORE_PATH_CACHE}/webhooks.json`;

        if (!existsSync(adapterFile)) {
            ensureFileSync(adapterFile);
        }

        this.database = lowdb(new FileSync(adapterFile));
        this.database.defaults({ webhooks: [] }).write();
    }
github Huachao / vscode-restclient / src / utils / httpRequestParser.ts View on Github external
private static resolveFilePath(refPath: string, httpFilePath: string): string | null {
        if (path.isAbsolute(refPath)) {
            return fs.existsSync(refPath) ? refPath : null;
        }

        let absolutePath;
        const rootPath = getWorkspaceRootPath();
        if (rootPath) {
            absolutePath = path.join(Uri.parse(rootPath).fsPath, refPath);
            if (fs.existsSync(absolutePath)) {
                return absolutePath;
            }
        }

        absolutePath = path.join(path.dirname(httpFilePath), refPath);
        if (fs.existsSync(absolutePath)) {
            return absolutePath;
        }
github superfly / fly / packages / core / src / file_app_store.ts View on Github external
constructor(options: FileAppStoreOptions) {
    this.appDir = options.appDir
    if (!fs.existsSync(this.appDir)) {
      throw new Error("Could not find path: " + this.appDir)
    }
    const stat = fs.statSync(this.appDir)
    if (!stat.isDirectory()) {
      this.appDir = path.dirname(this.appDir)
    }

    this.env = options.env

    this.buildDir = options.buildDir || path.join(this.appDir, ".fly", "build", this.env)
    if (!fs.existsSync(this.buildDir)) {
      fs.mkdirpSync(this.buildDir)
    }

    this.release = {
      app: options.app_name || this.appDir,
github quanglam2807 / translatium / public / libs / locales / index.js View on Github external
const initLocales = () => {
  let langId = getPreference('langId');
  if (!fsExtra.existsSync(path.resolve(__dirname, `${langId}.json`))) {
    langId = 'en';
  }

  locales = fsExtra.readJsonSync(path.resolve(__dirname, `${langId}.json`));
};