Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
grunt-shell
Advanced tools
Run shell commands
A good way to interact with other CLI tools. E.g. compiling Compass compass compile
or get the current git branch git branch
.
If you haven't used grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:
npm install --save-dev grunt-shell
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-shell');
Tip: the load-grunt-tasks module makes it easier to load multiple grunt tasks.
grunt.initConfig({
shell: { // Task
listFolders: { // Target
options: { // Options
stdout: true
},
command: 'ls'
}
}
});
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('default', ['shell']);
Create a folder named test
.
grunt.initConfig({
shell: {
makeDir: {
command: 'mkdir test'
}
}
});
The command
property supports templates:
grunt.initConfig({
testDir: 'test',
shell: {
makeDir: {
command: 'mkdir <%= testDir %>'
}
}
});
You can also supply a function that returns the command:
grunt.initConfig({
shell: {
hello: {
command: function () {
return 'echo hello';
}
}
}
});
Which can also take arguments:
shell: {
hello: {
command: function (greeting) {
return 'echo ' + greeting;
}
}
}
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('default', ['shell:hello']);
Output a directory listing in your Terminal.
grunt.initConfig({
shell: {
dirListing: {
command: 'ls',
options: {
stdout: true
}
}
}
});
Do whatever you want with the output.
function log(err, stdout, stderr, cb) {
console.log(stdout);
cb();
}
grunt.initConfig({
shell: {
dirListing: {
command: 'ls',
options: {
callback: log
}
}
}
});
Run a command in another directory. In this example we run it in a subfolder using the cwd
(current working directory) option.
grunt.initConfig({
shell: {
subfolderLs: {
command: 'ls',
options: {
stdout: true,
execOptions: {
cwd: 'tasks'
}
}
}
}
});
Run multiple commands by placing them in an array which is joined using &&
or ;
. &&
means run this only if the previous command succeeded. You can also use &
to have the commands run concurrently (by executing all commands except the last one in a subshell).
grunt.initConfig({
shell: {
multiple: {
command: [
'mkdir test',
'cd test',
'ls'
].join('&&')
}
}
});
Required
Type: String|Function
The command you want to run or a function which returns it. Supports underscore templates.
Default: false
Type: Boolean
Show stdout in the Terminal.
Default: false
Type: Boolean
Show stderr in the Terminal.
Default: true
Type: Boolean
Forward the terminal's stdin to the command.
Default: false
Type: Boolean
Fail task if it encounters an error. Does not apply if you specify a callback
.
Default: function () {}
Type: Function
Lets you override the default callback with your own.
Make sure to call the cb
method when you're done.
Default: undefined
Accepts: Object
Specify some options to be passed to the .exec() method:
cwd
String Current working directory of the child processenv
Object Environment key-value pairssetsid
Booleanencoding
String (Default: 'utf8')timeout
Number (Default: 0)maxBuffer
Number (Default: 200*1024)killSignal
String (Default: 'SIGTERM')MIT © Sindre Sorhus
FAQs
Run shell commands
The npm package grunt-shell receives a total of 59,599 weekly downloads. As such, grunt-shell popularity was classified as popular.
We found that grunt-shell demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.