How to use the fs-jetpack.exists function in fs-jetpack

To help you get started, we’ve selected a few fs-jetpack 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 zumwald / oss-attribution-generator / index.js View on Github external
function getBowerLicenses() {
    // first - check that this is even a bower project
    var baseDir;
    if (Array.isArray(options.baseDir)) {
        baseDir = options.baseDir[0];
        if (options.baseDir.length > 1) {
            console.warn("Checking multiple directories is not yet supported for Bower projects.\n" +
                "Checking only the first directory: " + baseDir);
        }
    }
    if (!jetpack.exists(path.join(baseDir, 'bower.json'))) {
        console.log('this does not look like a Bower project, skipping Bower checks.');
        return [];
    }

    bower.config.cwd = baseDir;
    var bowerComponentsDir = path.join(bower.config.cwd, bower.config.directory);
    return jetpack.inspectTreeAsync(bowerComponentsDir, { relativePath: true })
        .then((result) => {
            /**
             * for each component, try to calculate the license from the NPM package info
             * if it is a available because license-checker more closely aligns with our
             * objective.
             */
            return bluebird.map(result.children, (component) => {
                var absPath = path.join(bowerComponentsDir, component.relativePath);
                // npm license check didn't work
github NREL / OpenStudio-PAT / app / app / project / setProjectService.js View on Github external
}
            else if (jetpack.exists(oldZip) == false) {
              if (vm.Message.showDebug()) vm.$log.debug(oldZip + ' is not in project.');
            }
            else {
              vm.$log.error('jetpack.exists(' + oldZip + ') generated an unhandled return.');
            }

            if (jetpack.exists(oldJson) == 'file') {
              if (vm.Message.showDebug()) vm.$log.debug(oldJson + ' is in project, and is being renamed to ' + newJson + '.');
              jetpack.rename(oldJson, newJson);
            }
            else if (jetpack.exists(oldJson) == 'dir') {
              vm.$log.error(oldJson + ' is a directory, and not a file.');
            }
            else if (jetpack.exists(oldJson) == 'other') {
              vm.$log.error(oldJson + ' is an unknown type.');
            }
            else if (jetpack.exists(oldJson) == false) {
              if (vm.Message.showDebug()) vm.$log.debug(oldJson + ' is not in project.');
            }
            else {
              vm.$log.error('jetpack.exists(' + oldJson + ') generated an unhandled return.');
            }

            // set project Variables
            vm.setProjectVariables(projectDir);
            vm.$translate('toastr.projectSaved').then(translation => {
              vm.toastr.success(translation);
            });
            vm.$state.transitionTo('analysis', {}, {reload: true});
github RocketChat / Rocket.Chat.Electron / src / main / appData.js View on Github external
async function migrate() {
	const olderAppName = 'Rocket.Chat+';
	const dirName = process.env.NODE_ENV === 'production' ? olderAppName : `${ olderAppName } (${ process.env.NODE_ENV })`;
	const olderUserDataPath = path.join(app.getPath('appData'), dirName);

	try {
		await jetpack.copyAsync(olderUserDataPath, app.getPath('userData'), { overwrite: true });
		await jetpack.removeAsync(olderUserDataPath);
	} catch (error) {
		if (jetpack.exists(olderUserDataPath)) {
			throw error;
		}

		console.log('No data to migrate.');
	}
}
github zumwald / oss-attribution-generator / index.js View on Github external
return bluebird.map(keys, (key) => {
                console.log('processing', key);

                var package = result[key];
                var defaultPackagePath = `${package['dir']}/node_modules/${package.name}/package.json`;
      
                var itemAtPath = jetpack.exists(defaultPackagePath);
                var packagePath = [defaultPackagePath];
      
                if (itemAtPath !== 'file') {
                  packagePath = jetpack.find(package['dir'], {
                    matching: `**/node_modules/${package.name}/package.json`
                  });
                }
      
                var packageJson = "";
      
                if (packagePath && packagePath[0]) {
                  packageJson = jetpack.read(packagePath[0], 'json');
                } else {

                  return Promise.reject(`${package.name}: unable to locate package.json`);
                }
github z-edit / zedit / tasks / concat.js View on Github external
let load = function(path) {
    if (!jetpack.exists(path)) console.log(`ERROR: File not found at "${path}"`);
    let code = ensureTrailingNewLine(jetpack.read(path));
    const magicStr = new MagicString(code);
    concatFiles(magicStr, code, path);
    return magicStr.toString();
};
github apache / incubator-weex-cli / packages / @weex / core / src / toolbox / fs-tools.ts View on Github external
function isDirectory(path: string): boolean {
  return jetpack.exists(path) === 'dir'
}
github hello-efficiency-inc / raven-reader / src / renderer / db.js View on Github external
createOrReadDatabase (db) {
    const dirName = process.env.NODE_ENV === 'development' ? '.rss-reader-dev' : '.rss-reader'
    const existsDir = jetpack.exists(this.useDataDir.path(dirName))
    if (!existsDir) {
      fs.mkdir(this.useDataDir.path(`${dirName}`), (err) => {
        if (err) {}
      })
    }
    const existsArticle = fs.existsSync(this.useDataDir.path(`${dirName}/${db.article}`))
    const existsFeed = fs.existsSync(this.useDataDir.path(`${dirName}/${db.feed}`))
    const existsCategory = fs.existsSync(this.useDataDir.path(`${dirName}/${db.category}`))
    const database = {}

    if (!existsArticle && !existsFeed && !existsCategory) {
      this.useDataDir.write(this.useDataDir.path(`${dirName}/${db.article}`), '')
      this.useDataDir.write(this.useDataDir.path(`${dirName}/${db.feed}`), '')
      this.useDataDir.write(this.useDataDir.path(`${dirName}/${db.category}`), '')
    }
github protonmail-desktop / application / src / main / migrate-settings.js View on Github external
export const migrateSettings = () => {
  if (fs.exists(oldConfigPath)) {
    const oldConfig = JSON.parse(fs.read(oldConfigPath));
    
    Object.keys(oldConfig)
      .forEach(key => {
        settings.set(key, oldConfig[key]);
      });
    
    fs.remove(oldConfigPath);
  }
};
github hello-efficiency-inc / raven-reader / src / main / index.js View on Github external
function createWindow () {
  /**
   * If there is already data in old directory. Moved it to new
   */
  const oldDirectory = jetpack.cwd(app.getPath('userData'))
  const newDirectory = jetpack.cwd(app.getPath('home'))
  const existsArticle = jetpack.exists(oldDirectory.path('articles.db'))
  const existsFeed = jetpack.exists(oldDirectory.path('feeds.db'))
  const winURL = process.env.NODE_ENV === 'development' ? 'http://localhost:9080' : `file://${__dirname}/index.html`

  if (existsArticle && existsFeed) {
    jetpack.move(oldDirectory.path('feeds.db'), newDirectory.path('.rss-reader/feeds.db'))
    jetpack.move(oldDirectory.path('articles.db'), newDirectory.path('.rss-reader/articles.db'))
  }
  /**
   * Initial window options
   */
  mainWindow = new BrowserWindow({
    webPreferences: {
      webviewTag: true,
      nodeIntegration: true,
      nodeIntegrationInWorker: true,
      webSecurity: true
    },
github ericclemmons / polydev / src / middleware / notFound / index.js View on Github external
if (req.body.path !== req.path) {
        throw new Error(
          `Expected ${JSON.stringify(req.path)}, not ${JSON.stringify(
            req.body.path
          )}`
        )
      }

      const filepath = path.join(
        process.cwd(),
        "routes",
        req.path,
        `index${extension}`
      )

      if (jetpack.exists(filepath)) {
        throw new Error(`Route already exists at ${filepath}`)
      }

      const content = stripIndent(
        extension.startsWith(".ts")
          ? `
          import { Request, Response } from "express"

          export default (req: Request, res: Response) => {
            res.send("📝 ${req.path}")
          }
`
          : `
          module.exports = (req, res) => {
            res.send("📝 ${req.path}")
          }