How to use the fs-jetpack.path 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 bjonamu / ignite-react-app / src / extensions / ignite / pluginOverrides.js View on Github external
module.exports = context => {
  // grab ~/.irapp/overrides
  const overrideDir = jetpack.path(`${homeDir}`, '.irapp', 'overrides');

  // grab the environment var
  const envDir = process.env.IR_APP_PLUGIN_PATH || '';

  // sanitize & verify they exist
  return pipe(
    split(';'),
    map(trim),
    prepend(overrideDir),
    without(['', null]),
    uniq,
    filter(jetpack.exists)
  )(envDir);
};
github szwacz / scattered-store / spec / persistence.spec.js View on Github external
.then(() => {
      // Key 'abc' hashed with sha1: 'a9993e364706816aba3e25717850c26c9cd0d89d'
      const path = jetpack.path(testDir, 'a9', '993e364706816aba3e25717850c26c9cd0d89d');
      expect(jetpack.exists(path)).toBe('file');
      done();
    });
  });
github apache / incubator-weex-cli / packages / @weex / core / src / toolbox / meta-tools.ts View on Github external
const pkg = jetpack.path(directory, 'package.json')

    // if we find a package.json, we're done -- read the version and return it
    if (jetpack.exists(pkg) === 'file') {
      return jetpack.read(pkg, 'json').version
    }

    // if we reach the git repo or root, we can't determine the version -- this is where we bail
    const git = jetpack.path(directory, '.git')
    const root = jetpack.path('/')
    if (directory === root || jetpack.exists(git) === 'dir') {
      break
    }

    // go up another directory
    directory = jetpack.path(directory, '..')
  }
  throw new Error(`getVersion: Unknown CLI version (no package.json found in ${directory}`)
}
github apache / incubator-weex-cli / packages / @weex / core / src / toolbox / meta-tools.ts View on Github external
let directory = toolbox.runtime.defaultPlugin && toolbox.runtime.defaultPlugin.directory
  if (!directory) {
    throw new Error('getVersion: Unknown CLI version (no src folder found)')
  }

  // go at most 5 directories up to find the package.json
  for (let i = 0; i < 5; i += 1) {
    const pkg = jetpack.path(directory, 'package.json')

    // if we find a package.json, we're done -- read the version and return it
    if (jetpack.exists(pkg) === 'file') {
      return jetpack.read(pkg, 'json').version
    }

    // if we reach the git repo or root, we can't determine the version -- this is where we bail
    const git = jetpack.path(directory, '.git')
    const root = jetpack.path('/')
    if (directory === root || jetpack.exists(git) === 'dir') {
      break
    }

    // go up another directory
    directory = jetpack.path(directory, '..')
  }
  throw new Error(`getVersion: Unknown CLI version (no package.json found in ${directory}`)
}
github apache / incubator-weex-cli / packages / @weex / core / src / toolbox / meta-tools.ts View on Github external
export function getVersion(toolbox: IToolbox): string {
  let directory = toolbox.runtime.defaultPlugin && toolbox.runtime.defaultPlugin.directory
  if (!directory) {
    throw new Error('getVersion: Unknown CLI version (no src folder found)')
  }

  // go at most 5 directories up to find the package.json
  for (let i = 0; i < 5; i += 1) {
    const pkg = jetpack.path(directory, 'package.json')

    // if we find a package.json, we're done -- read the version and return it
    if (jetpack.exists(pkg) === 'file') {
      return jetpack.read(pkg, 'json').version
    }

    // if we reach the git repo or root, we can't determine the version -- this is where we bail
    const git = jetpack.path(directory, '.git')
    const root = jetpack.path('/')
    if (directory === root || jetpack.exists(git) === 'dir') {
      break
    }

    // go up another directory
    directory = jetpack.path(directory, '..')
  }
github szwacz / scattered-store / lib / lister.js View on Github external
const listNextSubdir = () => {
    if (this._subdirsToGo.length === 0) {
      // No more directories to list!
      deferred.reject('endOfPaths');
    } else {
      const subdir = this._subdirsToGo.pop();
      const path = jetpack.path(this._basePath, subdir);
      jetpack.listAsync(path)
      .then((filenames) => {
        // Generate absolute paths from filenames.
        this._pathsToGive = filenames.map((filename) => {
          return jetpack.path(path, filename);
        });
        if (this._pathsToGive.length > 0) {
          // Yep. We have paths. Done!
          deferred.resolve();
        } else {
          // This directory was apparently empty. Go for next one.
          listNextSubdir();
        }
      });
    }
  };
github filestack / filestack-js / rollup_cdn.config.js View on Github external
allowReserved: true,
  },
  plugins: [
    babel({
      exclude: 'node_modules/**',
    }),
    replace({
      delimiters: ['@{', '}'],
      values: {
        VERSION: manifest.version,
      },
    }),
    inject({
      exclude: 'node_modules/**',
      modules: {
        envGetter: jetpack.path(`config/env_${envName}.js`),
      },
    }),
    nodeResolve(),
    commonJs(),
    uglify({
      output: {
        // Leave topmost comment with version
        comments: (node, comment) => comment.line === 1,
      },
    }),
  ],
  targets: [
    {
      dest: 'dist_cdn/filestack.js',
      format: 'umd',
      banner: `/* v${manifest.version} */`,
github RocketChat / Rocket.Chat.Electron / src / scripts / servers.js View on Github external
hosts = {};
			oldHosts.forEach(function(item) {
				item = item.replace(/\/$/, '');
				hosts[item] = {
					title: item,
					url: item,
				};
			});
			localStorage.setItem(this.hostsKey, JSON.stringify(hosts));
		}

		// Load server info from server config file
		if (Object.keys(hosts).length === 0) {
			const { app } = remote;
			const userDir = jetpack.cwd(app.getPath('userData'));
			const appDir = jetpack.cwd(jetpack.path(app.getAppPath(), app.getAppPath().endsWith('.asar') ? '..' : '.'));
			const path = (userDir.find({ matching: 'servers.json', recursive: false })[0] && userDir.path('servers.json'))
				|| (appDir.find({ matching: 'servers.json', recursive: false })[0] && appDir.path('servers.json'));

			if (path) {
				try {
					const result = jetpack.read(path, 'json');
					if (result) {
						hosts = {};
						Object.keys(result).forEach((title) => {
							const url = result[title];
							hosts[url] = { title, url };
						});
						localStorage.setItem(this.hostsKey, JSON.stringify(hosts));
						// Assume user doesn't want sidebar if they only have one server
						if (Object.keys(hosts).length === 1) {
							localStorage.setItem('sidebar-closed', 'true');
github RocketChat / Rocket.Chat.Electron / src / main / downloads.js View on Github external
const createWillDownloadHandler = (dispatch, runSaga) => (event, item) => {
	const id = uniqid();

	// TODO: fix download file overwrite
	item.setSavePath(jetpack.path(app.getPath('downloads'), item.getFilename()));

	item.on('updated', () => {
		dispatch(downloadUpdated(createDownloadItem(id, item)));
	});

	item.once('done', () => {
		if (item.getState() === 'cancelled') {
			return;
		}
		dispatch(downloadUpdated(createDownloadItem(id, item)));
	});

	runSaga(function* handleClearDownload() {
		for (;;) {
			const { payload: _id } = yield take(DOWNLOAD_CLEARED);
			if (id !== _id || item.isDestroyed()) {