How to use the grep function from shelljs

Find comprehensive JavaScript shelljs.grep code examples handpicked from public code repositorys.

50
51
52
53
54
55
56
57
58
59
60
}


// Get valid target from framework/project.properties
module.exports.get_target = function() {
    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();
fork icon2
star icon0
watch icon0

193
194
195
196
197
198
199
200
201
202
    .setTargetSdkVersion(platformConfig.getPreference('android-targetSdkVersion', 'android'))
    .write();

var javaPattern = path.join(locations.root, 'src', orig_pkg.replace(/\./g, '/'), '*.java');
var java_files = shell.ls(javaPattern).filter(function(f) {
    return shell.grep(/extends\s+CordovaActivity/g, f);
});

if (java_files.length === 0) {
    throw new CordovaError('No Java files found that extend CordovaActivity.');
fork icon2
star icon0
watch icon0

118
119
120
121
122
123
124
125
126
127
128
129
        return started_emulator_list;
    });
}


module.exports.get_target = function() {
    var target = shell.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties'));
    return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
}


// Returns a promise.
fork icon1
star icon0
watch icon2

+ 10 other calls in file