karma-html2js-preprocessor
Advanced tools
Comparing version
@@ -12,4 +12,12 @@ var util = require('util'); | ||
var createHtml2JsPreprocessor = function(logger, basePath) { | ||
var createHtml2JsPreprocessor = function(logger, basePath, config) { | ||
config = typeof config === 'object' ? config : {}; | ||
var log = logger.create('preprocessor.html2js'); | ||
var stripPrefix = config.stripPrefix ? new RegExp('^' + config.stripPrefix) : null; | ||
var prependPrefix = config.prependPrefix ? config.prependPrefix : ''; | ||
var processPath = config.processPath || function(htmlPath) { | ||
htmlPath = prependPrefix + htmlPath.replace(stripPrefix, ''); | ||
return htmlPath; | ||
}; | ||
@@ -19,3 +27,3 @@ return function(content, file, done) { | ||
var htmlPath = file.originalPath.replace(basePath + '/', ''); | ||
var htmlPath = processPath(file.originalPath.replace(basePath + '/', '')); | ||
@@ -27,4 +35,4 @@ file.path = file.path + '.js'; | ||
createHtml2JsPreprocessor.$inject = ['logger', 'config.basePath']; | ||
createHtml2JsPreprocessor.$inject = ['logger', 'config.basePath', 'config.html2JsPreprocessor']; | ||
module.exports = createHtml2JsPreprocessor; |
{ | ||
"name": "karma-html2js-preprocessor", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A Karma plugin. Convert HTML files into JS strings to serve them in a script tag.", | ||
@@ -22,10 +22,10 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"grunt": "~0.4.1", | ||
"grunt": "~1.0.1", | ||
"grunt-simple-mocha": "~0.4", | ||
"grunt-contrib-jshint": "~0.6", | ||
"chai": "~1.4", | ||
"mocha": "~1.8", | ||
"grunt-contrib-jshint": "~1.0", | ||
"chai": "~3.5", | ||
"mocha": "~3.0", | ||
"grunt-npm": "~0.0.2", | ||
"grunt-bump": "~0.0.7", | ||
"grunt-auto-release": "~0.0.2" | ||
"grunt-bump": "~0.8.0", | ||
"grunt-auto-release": "~0.0.6" | ||
}, | ||
@@ -38,3 +38,5 @@ "peerDependencies": { | ||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>", | ||
"Mark Ethan Trostler <mark@zzo.com>", | ||
"Andres Rios <rianby64@gmail.com>", | ||
"Larry Davis <lazdnet@gmail.com>", | ||
"Jochen Ulrich <jochenulrich@t-online.de>", | ||
@@ -41,0 +43,0 @@ "Richard McIntyre <richard.mackstar@gmail.com>" |
@@ -25,3 +25,3 @@ # karma-html2js-preprocessor [](https://travis-ci.org/karma-runner/karma-html2js-preprocessor) | ||
## Configuration | ||
Following code shows the default configuration... | ||
```js | ||
@@ -38,3 +38,17 @@ // karma.conf.js | ||
'*.html' | ||
] | ||
], | ||
html2JsPreprocessor: { | ||
// strip this from the file path | ||
stripPrefix: 'public/', | ||
// prepend this to the file path | ||
prependPrefix: 'served/', | ||
// or define a custom transform function | ||
processPath: function(filePath) { | ||
// Drop the file extension | ||
return filePath.replace(/\.html$/, ''); | ||
} | ||
} | ||
}); | ||
@@ -41,0 +55,0 @@ }; |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
5453
17.32%29
31.82%78
21.88%