From 6583a53b7a10db08c4aa0ba5cad9b1a70ec8553d Mon Sep 17 00:00:00 2001 From: Yun Lai Date: Sun, 12 Jul 2015 17:54:10 +1000 Subject: [PATCH] added config runOnlyOnce for special cases. --- index.js | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7fa7bd5..95481ad 100644 --- a/index.js +++ b/index.js @@ -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); diff --git a/package.json b/package.json index 9626612..880d710 100644 --- a/package.json +++ b/package.json @@ -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": {