Skip to content

Commit

Permalink
added config runOnlyOnce for special cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
lyonlai committed Jul 12, 2015
1 parent d65a830 commit 6583a53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@ var runScriptOnChangePreprocessor = function(args, logger, config) {

var messageOnError = (config && config.messageOnError) || null;

var runOnlyOnce = (config && config.runOnlyOnce) || null;

var scriptHasRun = false;

return function(content, file, done) {
var result = null;

if(runOnlyOnce && scriptHasRun) {
log.debug('script has been executed, not gonna run again, exiting');
return done(null, content);
}

if (script) {
result = shell.exec(script);

scriptHasRun = true;
}

log.debug('shell execution result', result);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "karma-runscript-preprocessor",
"version": "0.0.4",
"version": "0.0.5",
"description": "run a script on file changed. it can bail the test running on script failed. it's suitable for using a single test-loader in karma-webpack.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 6583a53

Please sign in to comment.