How to use the shelljs.grep 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 flow-typed / flow-typed / definitions / npm / shelljs_v0.7.x / test_shelljs_v0.7.x.js View on Github external
// $ExpectError
sh.exit('');
// Success
(sh.exit(): void);
// Success
(sh.exit(0): void);

// $ExpectError
sh.find();
// $ExpectError
sh.find(0);
// Success
(sh.find('~', '/tmp'): ShellArray);

// $ExpectError
sh.grep();
// $ExpectError
sh.grep(0);
// $ExpectError
sh.grep({'-x': true }, 'type');
// $ExpectError
sh.grep({'-x': true }, 'type');
// $ExpectError
sh.grep({ '-x': true }, /type/, 'definitions/**/*.js');
// Success
(sh.grep({ '-l': true }, /type/, 'definitions/**/*.js'): ShellString);
// Success
(sh.grep({ '-l': true }, 'type', 'definitions/**/*.js'): ShellString);
// Success
(sh.grep('type', 'definitions/**/*.js'): ShellString);

// $ExpectError
github forcedotcom / salesforcedx-docker / scripts / publish.js View on Github external
// This needs to change when we are ready to publish
const DOCKER_HUB_REPOSITORY = 'salesforce/salesforcedx';

// Checks that you have the Docker CLI installed
if (!shell.which('docker')) {
  shell.echo('You do not have the Docker CLI installed.');
  shell.exit(-1);
}

// Checks that you have logged into docker hub
// Unfortunately I don't think there is a way to check what repositories you have access to
const AUTH_REGEX = '"https://index.docker.io/v1/"';
if (
  !new RegExp(AUTH_REGEX).test(
    shell.grep(AUTH_REGEX, '~/.docker/config.json').stdout
  )
) {
  shell.echo('You are not logged into Docker Hub. Try `docker login`.');
  shell.exit(-1);
}

// Checks that there are no uncommitted changes
const gitStatus = shell.exec(`git status --porcelain`).stdout.trim();
if (gitStatus) {
  shell.echo(
    'You have git changes in the current branch. You should probably not be releasing until you have commited your changes.'
  );
  shell.exit(-1);
}

const SALESFORCE_CLI_VERSION = process.env['SALESFORCE_CLI_VERSION'];
github holisticon / flynn-book-scanner / app / platforms / android / cordova / lib / check_reqs.js View on Github external
module.exports.get_target = function() {
    if(fs.existsSync(path.join(ROOT, 'framework', 'project.properties'))) {
        var target = shelljs.grep(/target=android-[\d+]/, path.join(ROOT, 'framework', 'project.properties'));
        return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
    } else if (fs.existsSync(path.join(ROOT, 'project.properties'))) {
        // if no target found, we're probably in a project and project.properties is in ROOT.
        // this is called on the project itself, and can support Google APIs AND Vanilla Android
        var target = shelljs.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties')) ||
          shelljs.grep(/target=Google Inc.:Google APIs:[\d+]/, path.join(ROOT, 'project.properties'));
        if(target == "" || !target) {
          // Try Google Glass APIs
          target = shelljs.grep(/target=Google Inc.:Glass Development Kit Preview:[\d+]/, path.join(ROOT, 'project.properties'));
        }
        return target.split('=')[1].replace('\n', '').replace('\r', '');
    }
}
github lsubel / amam-cordova / platforms / android / cordova / lib / check_reqs.js View on Github external
function extractFromFile (filePath) {
        var target = shelljs.grep(/\btarget=/, filePath);
        if (!target) {
            throw new Error('Could not find android target within: ' + filePath);
        }
        return target.split('=')[1].trim();
    }
    var repo_file = path.join(REPO_ROOT, 'framework', 'project.properties');
github vitrine-app / vitrine / scripts / build_modules.js View on Github external
const { readdir, statSync } = require('fs-extra');
const { resolve } = require('path');
const { cd, exec, grep, mkdir, mv, rm } = require('shelljs');


const electronUrl = 'https://atom.io/download/electron';
const electronVersion = grep('"electron":', 'package.json')
  .sed(/[ ]+"electron": "[\^]?(.*)"[,]?/, '$1')
  .replace(/\n/, '');

mkdir('-p', 'modules');
cd('sources/modules');

readdir(resolve()).then((modules) => {
  for (const module of modules.filter((module) => statSync(module).isDirectory())) {
    cd(module);
    exec(`${resolve('../../../node_modules/.bin/node-gyp')} rebuild --target=${electronVersion} --arch=x64 --dist-url=${electronUrl}`);
    mv(`build/Release/${module}.node`, '../../../modules');
    rm('-r', 'build');
    cd('-');
    console.log(`${module} build completed.`);
  }
});
github jjt / grunt-lodash-autobuild / tasks / lodash_autobuild.js View on Github external
this.files.forEach(function(f) {
      var files = grunt.file.expand(f.src),
          matchlines = shelljs.grep(lodashUsagePattern, files),
          matches = matchlines.match(new RegExp(lodashUsagePattern, 'gi'));

      if(!_.isArray(matches)) {
        return;
      }

      for(var i=0; i < matches.length; i++) {
        matches[i] = matches[i].split('.').slice(-1)[0];
      }

      props = props.concat(matches);
    });
github QuickBlox / quickblox-javascript-sdk / samples / cordova / text_chat / platforms / android / cordova / lib / check_reqs.js View on Github external
function extractFromFile(filePath) {
        var target = shelljs.grep(/\btarget=/, filePath);
        if (!target) {
            throw new Error('Could not find android target within: ' + filePath);
        }
        return target.split('=')[1].trim();
    }
    if (fs.existsSync(path.join(ROOT, 'framework', 'project.properties'))) {
github mclear / NFC_Ring_Control / platforms / android / cordova / lib / check_reqs.js View on Github external
function extractFromFile(filePath) {
        var target = shelljs.grep(/\btarget=/, filePath);
        if (!target) {
            throw new Error('Could not find android target within: ' + filePath);
        }
        return target.split('=')[1].trim();
    }
    if (fs.existsSync(path.join(ROOT, 'framework', 'project.properties'))) {
github myFace-KYC / Identity_Verification / node_modules / cordova-android / bin / templates / cordova / lib / prepare.js View on Github external
var java_files = shell.ls(javaPattern).filter(function (f) {
        return shell.grep(/extends\s+CordovaActivity/g, f);
    });