How to use the shelljs.test function in shelljs

To help you get started, we’ve selected a few shelljs 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 poetic / reacterminator / test / unit / lib / helpers / clean-folder.js View on Github external
it('should not create the path if it already exist', function () {
    const folderPath = path.resolve('./reacterminator')

    shell.mkdir(folderPath)
    const notCustomPath = path.resolve(folderPath, 'not-custom.js')
    fs.writeFileSync(notCustomPath, '/* eslint-disable */\nnot custom')
    const customPath = path.resolve(folderPath, 'custom.js')
    fs.writeFileSync(customPath, '//')

    cleanFolder(folderPath)

    assert(!shell.test('-f', notCustomPath), 'generated file should not exist')
    assert(shell.test('-f', customPath), 'custom file should exist')
  })
})
github nytimes / kyt / packages / kyt-core / cli / commands.js View on Github external
const logger = require('kyt-utils/logger');
const { userPackageJSONPath } = require('kyt-utils/paths')();
const devAction = require('./actions/dev');
const lintScriptAction = require('./actions/lintScript');
const testAction = require('./actions/test');
const buildAction = require('./actions/build');
const protoAction = require('./actions/proto');
const lintStyleAction = require('./actions/lintStyle');
const kytConfigFn = require('./../utils/kytConfig');

// Comment the following to see verbose shell ouput.
shell.config.silent = true;

// Kill the process if the user did not run
// the command from the root of their project.
if (!shell.test('-f', userPackageJSONPath)) {
  logger.error(`kyt works best when you execute commands
    from the root of your project where kyt is installed.`);
  process.exit(1);
}

process.on('SIGINT', () => {
  logger.warn('kyt interrupted ☝️');
  process.exit(0);
});

const loadConfigAndDo = (action, optionalConfig) => {
  const args = program.args.filter(item => typeof item === 'object');
  const flags = program.args.filter(item => typeof item === 'string');
  const config = kytConfigFn(optionalConfig);
  action(config, flags, args[0]);
};
github infinitered / ignite / ignite-cli / src / index.es View on Github external
.action((type) => {
    const platform = process.platform
    const ignitePath = R.trim(Shell.which('ignite'))
    const igniteVersion = R.trim(Shell.exec('ignite -V', { silent: true }).stdout)
    const nodePath = R.trim(Shell.which('node'))
    const npmVersion = R.trim(Shell.exec('npm --version', { silent: true }).stdout)
    const npmPath = R.trim(Shell.which('npm'))
    const nodeVersion = R.trim(Shell.exec('node --version', { silent: true }).stdout)
    const yoVersion = R.trim(Shell.exec('yo --version', { silent: true }).stdout)
    const rnCli = R.split(/\s/, R.trim(Shell.exec('react-native --version', { silent: true }).stdout))[1] // lulz

    const rnPackageFile = `${process.cwd()}/node_modules/react-native/package.json`
    const appReactNativeVersion = Shell.test('-f', rnPackageFile) ? require(rnPackageFile).version : '¯\\_(ツ)_/¯'

    const body = `
\`\`\`
Computer
  Platform: ${platform}

Ignite
  Version: ${igniteVersion}
  Path: ${ignitePath}

Node
  Version: ${nodeVersion}
  Path: ${nodePath}

NPM
  Version: ${npmVersion}
github Datawheel / canon / bin / server / index.js View on Github external
async function start() {

  /* Detects which directories to load server files from ("api/", "db/", etc) */
  title("Detecting Canon Plugins", "🧩");
  const modules = [rootPath];
  const moduleFolder = path.join(rootPath, "node_modules/@datawheel/");
  if (shell.test("-d", moduleFolder)) {
    fs.readdirSync(moduleFolder)
      .forEach(folder => {
        const fullPath = path.join(moduleFolder, folder);
        shell.echo(moduleName(fullPath) || folder);
        modules.unshift(path.join(fullPath, "src/"));
      });
  }
  else {
    shell.echo("no canon plugins detected");
  }
  if (name.includes("@datawheel/canon")) modules.unshift(path.join(rootPath, "src/"));

  title("Registering Services", "🛎️");

  const opbeatApp = process.env.CANON_OPBEAT_APP;
  const opbeatOrg = process.env.CANON_OPBEAT_ORG;
github crosswalk-project / crosswalk-app-tools / src / util / Download01Org.js View on Github external
function(version) {

    var filename = this.buildFilename(version);
    if (ShellJS.test("-f", filename))  {
        return filename;
    } else if (ShellJS.test("-f", "../" + filename)) {
        // Also try parent dir.
        // This is especially useful for tests that run in a temporary dir.
        return "../" + filename;
    }

    return null;
};
github sc-forks / solidity-coverage / test / util / verifiers.js View on Github external
function pathExists(path) { return shell.test('-e', path); }
github standard / standard-demo / prep-eslint.js View on Github external
function cloneOrPull (repo, dir) {
  if (sh.test('-d', dir)) {
    sh.pushd(dir)
    sh.exec('git pull')
    sh.exec('npm install --production')
    sh.popd()
  } else {
    sh.exec('git clone ' + repo + ' ' + dir)
  }
}
github jamesshore / lets_code_javascript / node_modules / jshint / src / cli.js View on Github external
function collect(fp, files, ignores, ext) {
  if (ignores && isIgnored(fp, ignores)) {
    return;
  }

  if (!shjs.test("-e", fp)) {
    cli.error("Can't open " + fp);
    return;
  }

  if (shjs.test("-d", fp)) {
    shjs.ls(fp).forEach(function(item) {
      var itempath = path.join(fp, item);
      if (shjs.test("-d", itempath) || item.match(ext)) {
        collect(itempath, files, ignores, ext);
      }
    });

    return;
  }

  files.push(fp);
}
github victorporof / Sublime-JSHint / scripts / node_modules / jshint / src / cli.js View on Github external
function findFile(name, cwd) {
  cwd = cwd || process.cwd();

  var filename = path.normalize(path.join(cwd, name));
  if (findFileResults[filename] !== undefined) {
    return findFileResults[filename];
  }

  var parent = path.resolve(cwd, "../");

  if (shjs.test("-e", filename)) {
    findFileResults[filename] = filename;
    return filename;
  }

  if (cwd === parent) {
    findFileResults[filename] = null;
    return null;
  }

  return findFile(name, parent);
}
github apache / cordova-windows / template / cordova / lib / build.js View on Github external
function cleanIntermediates () {
    var buildPath = path.join(ROOT, 'build');
    if (shell.test('-e', buildPath)) {
        shell.rm('-rf', buildPath);
    }
}