How to use the shelljs.find 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 eslint / typescript-eslint-parser / tests / lib / tsx.js View on Github external
//------------------------------------------------------------------------------

const
    path = require("path"),
    { Linter } = require("eslint"),
    shelljs = require("shelljs"),
    parser = require("../../"),
    testUtils = require("../../tools/test-utils");

//------------------------------------------------------------------------------
// Setup
//------------------------------------------------------------------------------

const TSX_FIXTURES_DIR = "./tests/fixtures/tsx";

const testFiles = shelljs.find(TSX_FIXTURES_DIR)
    .filter(filename => filename.indexOf(".src.tsx") > -1)
    // strip off ".src.tsx"
    .map(filename => filename.substring(TSX_FIXTURES_DIR.length - 1, filename.length - 8));

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

describe("TSX", () => {
    testFiles.forEach(filename => {
        const code = shelljs.cat(`${path.resolve(TSX_FIXTURES_DIR, filename)}.src.tsx`);
        const config = {
            useJSXTextNode: true,
            jsx: true
        };
        test(`fixtures/${filename}.src`, testUtils.createSnapshotTestBlock(code, config));
github eslint / espree / tests / lib / ecma-version.js View on Github external
const leche = require("leche"),
    path = require("path"),
    shelljs = require("shelljs"),
    tester = require("./tester"),
    espree = require("../../espree"),
    assert = require("assert");

// var espree = require("esprima-fb");
//------------------------------------------------------------------------------
// Setup
//------------------------------------------------------------------------------

const FIXTURES_DIR = "./tests/fixtures/ecma-version/";

const allTestFiles = shelljs.find(FIXTURES_DIR)
    .filter(filename => filename.indexOf(".src.js") > -1)
    .map(filename => filename.slice(FIXTURES_DIR.length - 2, filename.length - 7)); // strip off ".src.js"


const scriptOnlyTestFiles = allTestFiles.filter(filename => filename.indexOf("modules") === -1);

const moduleTestFiles = allTestFiles.filter(filename => filename.indexOf("not-strict") === -1 && filename.indexOf("edge-cases") === -1);

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

describe("ecmaVersion", () => {

    let config;
github Kitware / visualizer / bin / pvw-visualizer-cli.js View on Github external
try {
      if (fs.statSync(directory).isDirectory()) {
        paraview.push(directory);
      }
    } catch (err) {
      // skip
    }
  });
}

if (!process.argv.slice(2).length || !program.help || paraview.length === 0) {
  program.outputHelp();
  process.exit(0);
}

const pvPythonExecs = shell.find(paraview).filter(function(file) {
  return file.match(/pvpython$/) || file.match(/pvpython.exe$/);
});
if (pvPythonExecs.length < 1) {
  console.log(
    'Could not find pvpython in your ParaView HOME directory ($PARAVIEW_HOME)'
  );
  program.outputHelp();
} else {
  const cmdLine = [
    quotePath(pvPythonExecs[0]),
    '-dr',
    quotePath(
      path.normalize(path.join(__dirname, '../server/pvw-visualizer.py'))
    ),
    '--content',
    quotePath(path.normalize(path.join(__dirname, '../dist'))),
github kkemple / tasker / server.js View on Github external
express = require('express'),
    app = express(),
    http = require('http'),
    bodyParser = require('body-parser'),
    favicon = require('serve-favicon'),
    shell = require('shelljs');


app.use(bodyParser.json());
app.use(express.static(__dirname + '/static'));
app.use(favicon(__dirname + '/static/favicon.ico'));
app.set('port', process.env.PORT || 8888);
app.set('views', __dirname + '/express/views');

// load endpoints
var routes = shell.find('express/routes').filter(function(file) {
    return file.match(/\.js$/);
});

routes.forEach(function(route) {
    require('./' + route)(app);
});

// create and run the server
http.createServer(app).listen(app.get('port'), function() {
    "use strict";

    console.log('Express server listening on port ' + app.get('port'));
});
github twbs / bootstrap / build / mixins-documentation.js View on Github external
const readLine = require('readline')
const sh = require('shelljs')
const Stream = require('stream')

const stylelintLineRegex = /\s*?\/\/\s?stylelint.*/

let mixinName
let mixin
let mixinDocumentation = ''
let inMixin = false
let output = ''

sh.config.fatal = true

// Find all files in mixins folder; returns Array
const scss = sh.find('./scss/mixins/**/*.scss')

scss.forEach((file) => {
  const inStream = fs.createReadStream(file)
  const OutStream = new Stream()
  const rl = readLine.createInterface(inStream, OutStream)

  // Loop through all lines
  rl.on('line', (line) => {
    if (!inMixin) {
      // Add documentation
      if (line.startsWith('//')) {
        // Ignore stylelint comments
        if (!stylelintLineRegex.test(line)) {
          mixinDocumentation += `${line.slice(2).trim()}\n`
        }
      } else if (line === '') {
github yasaricli / pmteor / imports / api / applications / server / helpers.js View on Github external
this.notification({
      type: 'info',
      message: TAPi18n.__('build-started', this.name)
    });

    // async sleep statements
    Meteor.sleep(50);

    // GO TO APPLICATION DIR
    cd(`${this.dir()}/programs/server`);

    // GO NPM PACKAGES
    cd('npm');

    // BINARY NPM MODULES
    const bindingFiles = find('.').filter((file) => {
      return file.match(/\.gyp$/);
    });

    bindingFiles.forEach((file) => {
      const dir = file.replace('/binding.gyp', '');

      // async sleep statements
      Meteor.sleep(100);

      // GO TO BINDING FILE DIR
      cd(dir);

      // REMOVE BEFORE MODULES
      rm('-rf', 'node_modules');

      // INSTALL MODULES
github silvenon / generator-wbp / test / tests.js View on Github external
it('should use react with addons everywhere', () => {
      shell.find(['app/scripts', 'test'])
        .filter((file) => file.match(/\.jsx$/))
        .forEach((file) => assert.noFileContent(file, "'react'"));
    });
github AxaGuilDEv / react-toolkit / scripts / prepare.js View on Github external
`${packageJson.name}@${packageJson.version}`
    )}`
  );
}

function copyReadmeToDist(){
  const modulePath = path.resolve('./');
  const readmePath = path.join(modulePath, 'README.md');
  if (fs.existsSync(readmePath)) {
    shell.cp(readmePath, path.join(modulePath, 'dist'));
  }
}

const packageJson = getPackageJson();

const tsFiles = shell.find('src').filter(tsFile => tsFile.match(/\.ts$/));

if (tsFiles.length !== 0) {
  tscfy({ errorCallback: () => logError('ts', packageJson) });
} else {
  babelify({ errorCallback: () => logError('js', packageJson) });
}
copyLicence();

copyReadmeToDist();

console.log(
  chalk.gray(
    `Built: ${chalk.bold(`${packageJson.name}@${packageJson.version}`)}`
  )
);
github bakery / baker / .baker / generators / base.js View on Github external
_listAvailableBoilerPlates() {
    const excludeBoilerplates = [...this.navigationBoilerplates];
    const boilerplatesPath = this.templatePath('./boilerplates');

    const boilerplates = _.uniq(
      shell.find(boilerplatesPath).filter(file => file.match(/\.js.hbs$/i))
        .map(file => (/\/([a-zA-Z0-9\/]+)(\.ios|\.android)?\.js\.hbs$/ig).exec(
          file.split(boilerplatesPath)[1])[1]
        )
    );

    return boilerplates.filter(b => excludeBoilerplates.indexOf(b) === -1);
  },
github qooxdoo / qooxdoo / Gruntfile.js View on Github external
function() {
      var dirs = shell.find('.').filter(function(file) {
        return file.match(/node_modules$/);
      }).forEach(function(path) {
        shell.rm('-rf', path);
      });
    }
  );