spalger / grunt-run Goto Github PK
View Code? Open in Web Editor NEWInvite external commands into your grunt process with three tasks run, wait and stop.
License: MIT License
Invite external commands into your grunt process with three tasks run, wait and stop.
License: MIT License
If run:codecept
fails it returns exit code 1, which I want so that my CI service knows it didn't pass, the remaining stop:xxx
commands don't run it seems though or for some reason the php process is still running so the next time I run grunt test
the port is still bound to. Can grunt-run return an error code from the run:codcept
command? Is there a better way to do this maybe?
module.exports = function(grunt) {
var phantomjs = require('phantomjs');
var phantombin = phantomjs.path;
grunt.initConfig({
run: {
phantomjs: {
options: {
wait: false,
quiet: true,
ready: /running on port/
},
cmd: phantombin,
args: [
'--webdriver=4444'
],
},
codecept: {
wait: true,
quiet: false,
cmd: "vendor/bin/codecept",
args: [
'run'
],
},
artisan: {
options: {
wait: false,
quiet: true,
ready: /Laravel development server started/,
},
cmd: './artisan',
args: [
'serve'
],
},
},
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-run');
grunt.registerTask('default', []);
grunt.registerTask('test', ['run:phantomjs', 'run:artisan', 'run:codecept', 'stop:phantomjs', 'stop:artisan']);
};
Hi,
I want to use your script to call git rev-parse HEAD
and get the current commit hash in git, but I can't figure out how to use the return of the script inside of grunt.
is there a way to tell your plugin to record the output of the script into a grunt argument? like grunt.myCommitHash
?
thanks
Hello,
I am not able to run a command file wich is in the same directory as my Gruntfile.
It shows the following error :
`Running "run:dev" (run) task
Error: spawn upload-livy.cmd ENOENT
Warning: non-zero exit code -2 Use --force to continue.
Aborted due to warnings.`
However, I am able to run directly the command in my Terminal. Do you have any idea of how I can solve this issue ?
Thanks,
Benjamin
When trying to run protractor tests using grunt-run and protractor-flake, I'm facing the following:
Running "run:protractor-flake" (run) task
**you must either specify a configuration file or at least 3 options. See below for the options:
Usage: protractor [configFile] [options]
configFile defaults to protractor.conf.js
The [options] object will override values from the config file.
See the reference config for a full list of options.
Options:
--help Print Protractor help menu
--version Print Protractor version
--browser, --capabilities.browserName Browsername, e.g. chrome or firefox
--seleniumAddress A running selenium address to use
--seleniumSessionId Attaching an existing session id
...
Please, refer to the following issue for more details. This was first opened against protractor-flake, but they mentioned that it may be an issue with grunt-run: NickTomlin/protractor-flake#40
As of 1fce0ca grunt-run has lost ES5 compatibility.
Ideally we'd add a babel compile (or remove the string templating) to still support people stuck on old versions of node.
I am facing a strange issue.
I start java process using grunt-run plugin putting it into background ({wait: true}) passing control to another task which talks to the first one over http. The first one starts logging lots of messages after a while, which causes everything to hang.
If I decrease logging level, then everything works fine.
It seems like a bug to me.
Thanks,
Marcin
Cannot find a way of calling a command like so: tsc reinstall -roc
run: {
tsdInstall: {
cwd: './resources/ts',
cmd: './node_modules/typescript/bin/tsc',
args: ['reinstall', '-ros']
}
},
Hi,
That's not a bug, just FYI. Grunt-run with lodash 4.2.0 gives an error undefined is not a function
.
There're big amount of breaking changes in the new lodash. For example they've replaced _.contains
with _.includes
, so grunt-run fails here: https://github.com/spalger/grunt-run/blob/master/tasks/run.js#L74
Hello!
According to the docs, the process should be killed on failOnError: true
, and with wait: true
the task should be failed, but I don't see this happening. (Nor do I actually saw any code related to this in run.js.)
// from a Gruntfile.js
run: {
t: {
options: { failOnError: true, wait: true },
args: ['t.js']
},
# t.js
console.log("this goes to stdout ");
console.error(" this goes to stderr ");
And there is output on stderr:
pas@strange:~/$ node t.js 1>/dev/null
this goes to stderr
Yet
pas@strange:~/$ grunt run:t
Running "run:t" (run) task
this goes to stdout
this goes to stderr
Done, without errors.
Luckily exit-code checking works wonderfully with wait.
Could you look into this?
Thanks.
Example configuration which fails on Linux:
options: {
failOnError: true
},
updateAllPackages: {
exec: '/workspace/Some project name (branch 2.10)/updateAllPackages'
}
It fails because the 'exec' value is not escaped with quotes here (while the Windows variant is):
if (this.data.exec) {
// logic is from node's cp.exec method, adapted to benefit from
// streaming io
if (process.platform === 'win32') {
cmd = 'cmd.exe';
args = ['/s', '/c', '"' + this.data.exec + '"'];
spawnOpts.windowsVerbatimArguments = true;
} else {
cmd = '/bin/sh';
args = ['-c', this.data.exec];
}
Please change args = ['-c', this.data.exec];
to args = ['-c', '"' + this.data.exec + '"'];
on row 112.
I have got the following configuration and second stop doesn't stop the server, it prints >> server already stopped
, which is not true.
After some debugging, I found that clearPid
is invoked by proc.on('close'
from within trackBackgroundProc
grunt-run: 0.5.1
node: 0.10.40
run: {
server: {
args: ['server.js'],
options: {
cwd: 'site',
wait: false,
quiet: true,
failOnError: true
}
}
}
grunt.registerTask('one', function(){grunt.log.ok('First run')});
grunt.registerTask('two', function(){grunt.log.ok('Second run')});
grunt.registerTask('myrun', ['env:csa','run:server',
'one',
'stop:server',
'run:server',
'two',
'stop:server']);
added a PR
Requesting support for environment variables when defining a target as shown below:
grunt.initConfig({
run: {
options: {
// Task-specific options go here.
},
your_target: {
cmd: 'executable',
env:{
'NODE_ENV': 'production'
},
args: [
'arg1',
'arg2'
]
}
}
})
At the moment npm throws an error about unmet peer dependencies when using Grunt 1.x. This also means our CI breaks. Please update the grunt peer dependency ASAP so we can use this plugin with Grunt 1.0! Thanks!
if (additionalArgs.length) {
if(process.platform === 'win32') {
args[2]+= ' ' + additionalArgs.join(' ');
} else {
args[1]+= ' ' + additionalArgs.join(' ');
}
}
From Grunt I want to execute a script as one of the tasks. I'm not interested in the status of the script. When I download the project first time from repository, the script has default permission of read only. On executing grunt task, i want to change the permission and run the file.
My Gruntfile.js looks like this:
run: {
options: {
// Task-specific options go here.
},
start_script: {
cmd: 'chmod +x some_script.sh && ./some_script.sh', <-- results in Error: spawn ENONT
// cmd: './some_script.sh', <-- results in Error: spawn EACCES
args: []
}
}
grunt.loadNpmTasks('grunt-run');
grunt.registerTask('install', ['run']);
Can you let me know if this is even possible? or cmd is used only to execute scripts that have write permissions?
When you try to stop a task in a watch when which was started before you get the following error:
Running "stop:server" (stop) task
Verifying property stop.server exists in config...ERROR
>> Unable to process task.
Warning: Required config property "stop.server" missing. Use --force to continue.
Aborted due to warnings.
This might be by design because watch starts a new grunt process or something, but i feel like it should work. Example grunt file:
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
watch: {
ts: {
files: ['**/*.ts'],
tasks: ['stop:server', 'build', 'run:server']
}
},
run: {
server: {
options: {
wait: false,
ready: /.*Listening on port.*/ig
},
args: ['./dist/app/index.js'],
}
},
ts: {
src: {
tsconfig: true
}
}
});
grunt.registerTask('build', ['clean', 'ts']);
grunt.registerTask('serve', ['build', 'run:server', 'watch']);
}
Trying to console.log
a larger JSON object within the script I run, but the end keeps getting chopped off so I can't see the full result.
Is this supposed to happen by default?
Any workarounds to see full logs?
line 44 :
var opts = this.options({ wait: true, failOnError: false, quite: false, ready: 1000, cwd: process.cwd(), passArgs: [], itterable: false });
For using regexp detecting process ready, the process data may send out into process.stderr.
For example, java -jar selenium-standalone.jar
need something like
proc.stderr.on('data', function checkForReady(chunk) {...})
I'm getting this error when trying to use it on nodejs versions >= 0.10, is there any way to fix it (or at least document the versions requirements)?
I tried a simple test task:
run: {
cwd: 'some/sub/dir',
cmd: 'pwd'
}
But it prints out the project's root directory, not the subdirectory.
Hi,
I'm trying to run redis-cli
or mongo
from Grunt with the grunt-run module and it does not work.
Actually it seems to work but the applications are exiting right away.
I would like to run something like grunt mongo:staging
and have access to the mongo
prompt of our staging database.
Any idea if this is possible?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.