Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(sh.ShellString("foo"): ShellResult);
// Success
(sh.ShellString("foo"): String);
// Success
(sh.ShellString(["foo", "bar"]): ShellArray);
// Success
(sh.ShellString(["foo", "bar"]): ShellResult);
// Success
(sh.ShellString(["foo", "bar"]): Array);
// $ExpectError
sh.cat();
// $ExpectError
sh.cat(0);
// Success
(sh.cat('/dev/null'): ShellString);
// $ExpectError
sh.cd(0);
// Success
(sh.cd(): ShellString);
// Success
(sh.cd('/tmp'): ShellString);
// $ExpectError
sh.chmod();
// $ExpectError
sh.chmod(755);
// $ExpectError
sh.chmod('nope', 755, '~');
// $ExpectError
sh.chmod({ '-x': true }, 755, '~');
function parse(from) { return compiler.compile(sh.cat(from).replace(/^\uFEFF/g, /* strips BOM */''), opt.compiler) }
function toFile(from, to) { encapsulate(from.map(function (path, i) { return parse(path) }).join('\n')).to(to[0]) }
getLines(filePath) {
if (_.isArray(filePath)) return filePath;
return shell.cat(filePath).split('\n').map(line => line.replace(/\r/g, ''));
},
let mergeSettings = (filename) => {
if (!sh.test('-f', filename)) { return; }
let newSettings;
try {
newSettings = yaml.safeLoad(sh.cat(filename));
} catch (ex) {
halt(`Failed to open settings file: ${filename}.\nException: ${ex}`);
}
merge(settings, newSettings);
}
function loadIgnores(params) {
var file = findFile(params.excludePath || ".jshintignore", params.cwd) || "";
if (!file && !params.exclude) {
return [];
}
var lines = (file ? shjs.cat(file) : "").split("\n");
var exclude = params.exclude || "";
lines.unshift.apply(lines, exclude.split(","));
return lines
.filter(function(line) {
return !!line.trim();
})
.map(function(line) {
if (line[0] === "!")
return "!" + path.resolve(path.dirname(file), line.substr(1).trim());
return path.join(path.dirname(file), line.trim());
});
}
function loadIgnores(exclude, excludePath) {
var file = findFile(excludePath || ".jshintignore");
if (!file && !exclude) {
return [];
}
var lines = (file ? shjs.cat(file) : "").split("\n");
lines.unshift(exclude || "");
return lines
.filter(function (line) {
return !!line.trim();
})
.map(function (line) {
if (line[0] === "!")
return "!" + path.resolve(path.dirname(file), line.substr(1).trim());
return path.join(path.dirname(file), line.trim());
});
}
config.prereq.forEach(function (fp) {
fp = path.join(config.dirname, fp);
if (shjs.test("-e", fp))
buffer.push(shjs.cat(fp));
});
delete config.prereq;
const getCommitData = () => {
const commits = [];
/*
* If the special file were Git stores the commit message exists,
* it most probably means this script is executed when the user
* does a commit, so we only need to get the current commit message.
*/
if (shell.test('-f', COMMIT_MESSAGE_FILE)) {
commits.push({
files: getCommittedFiles(),
message: shell.cat(COMMIT_MESSAGE_FILE),
sha: null
});
/*
* Otherwise, it means this script is execute as part of the tests,
* and since there is no easy way to know how many new commits were
* added, check all commits since the last release.
*/
} else {
const commitSHAsSinceLastRelease = shell.exec(`git rev-list HEAD...${PKG.version}`).stdout.split('\n');
commitSHAsSinceLastRelease.forEach((sha) => {
commits.push({
message: shell.exec(`git show --no-patch --format=%B ${sha}`).stdout.trim(),
sha,
exports.getSystemConfigContent = function (req, res) {
var config = shell.cat(path.resolve(req.query.filename));
if (req.user.isAdmin) {
res.json({
configContent: config
});
} else {
return res.status(403).json({
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
});
}
};
function getLininoShieldsRegistered(){
var shields = [];
if(fs.existsSync('/sys/devices/mcuio/shield_list')){
var str = shell.cat('/sys/devices/mcuio/shield_list');
var _shields = S(S(str).trim().s).parseCSV('\n',"");
_shields.forEach(function(val,ind){
if(S(val).contains('*')){
val = S(val).replaceAll('*','').s;
val = S(val).trim().s;
shields.push(val);
}
});
}
return shields;
}
//return true if the shield can be registered