Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
grunt-shell
Advanced tools
Requires grunt 0.4. Use version 0.1.4 for grunt 0.3 compatibility
Grunt task to 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 grunt-shell --save-dev
Create a folder named test
.
shell: {
makeDir: {
command: 'mkdir test'
}
}
The command
property supports templates :
testDir: 'test',
shell: {
makeDir: {
command: 'mkdir <%= testDir %>'
}
}
Output a directory listing in your Terminal.
shell: {
dirListing: {
command: 'ls',
options: {
stdout: true
}
}
}
Do whatever you want with the output.
function log(err, stdout, stderr, cb) {
console.log(stdout);
}
...
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.
shell: {
subfolderLs: {
command: 'ls',
options: {
stdout: true,
execOptions: {
cwd: 'tasks'
}
}
}
}
Required
Type: String
The command you want to run. Supports templates.
Default: false
Type: Boolean
Show stdout in the Terminal.
Default: false
Type: Boolean
Show stderr in the Terminal.
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')Because of the transition to grunt 0.4 there are some changes. To conform to new grunt standards, all options are now to be specified in an options
object. I also took the opportunity to improve the task. The stdout
and stderr
options now only supports a boolean. If you want to do something with the result use the callback
option. The callback
option also changed.
Grunt currently doesn't have a way to test tasks directly. You can test this task by running grunt
and manually verify that it works.
In lieu of a formal styleguide, take care to maintain the existing coding style.
MIT License (c) Sindre Sorhus
FAQs
Run shell commands
The npm package grunt-shell receives a total of 58,185 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.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.