Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// $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
// 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'];
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', '');
}
}
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');
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.`);
}
});
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);
});
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'))) {
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'))) {
var java_files = shell.ls(javaPattern).filter(function (f) {
return shell.grep(/extends\s+CordovaActivity/g, f);
});