gulp-assign
Advanced tools
Comparing version 0.2.1 to 0.2.2
14
index.js
@@ -17,2 +17,3 @@ 'use strict'; | ||
pathIsAbsolute = path.isAbsolute, | ||
isString = is.string, | ||
isFunction = is.function, | ||
@@ -23,4 +24,4 @@ isPlainObject = is.plainObject, | ||
SPLITS = /<!--\s*build:(?:styles|scripts)(?::[\w-]*)?\s*(?:\s+\S+?|"[^"]+"|'[^']+')\s*-->[^]*?<!--\s*endbuild\s*-->/, | ||
BLOCKS = /<!--\s*build:(styles|scripts)(?::([\w-]*))?\s*(\s+\S+?|"[^"]+"|'[^']+')\s*-->([^]*?)<!--\s*endbuild\s*-->/g, | ||
SPLITS = /<!--\s*build:(?:styles|scripts|css|js|style|script)(?::[\w-]*)?\s*(?:\s+\S+?|"[^"]+"|'[^']+')\s*-->[^]*?<!--\s*endbuild\s*-->/, | ||
BLOCKS = /<!--\s*build:(styles|scripts|css|js|style|script)(?::([\w-]*))?\s*(\s+\S+?|"[^"]+"|'[^']+')\s*-->([^]*?)<!--\s*endbuild\s*-->/g, | ||
INPUTS = { | ||
@@ -123,2 +124,11 @@ styles: /<\s*link\b[^>]*\bhref\s*=\s*("[^"]+"|'[^']+'|[^\s>]+)[^>]*>/gi, | ||
if (!output) { | ||
output = outputOriginal; | ||
} else if (isPlainObject(output)) { | ||
output = ouput.original; | ||
} | ||
if (!output || !isString(output)) { | ||
return callback(new PluginError(PLUGIN_NAME, 'Invalid output path')); | ||
} | ||
output = OUTPUTS[type].replace('${output}', output); | ||
@@ -125,0 +135,0 @@ finish( |
'use strict'; | ||
module.exports = { | ||
string: function(x) { | ||
return typeof x === 'string'; | ||
}, | ||
function: function(x) { | ||
@@ -5,0 +8,0 @@ return typeof x === 'function'; |
{ | ||
"name": "gulp-assign", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"main": "index.js", | ||
@@ -15,5 +15,7 @@ "dependencies": { | ||
"mocha": "^2.3.4", | ||
"run-sequence": "^1.1.5", | ||
"sinon": "^1.17.2" | ||
}, | ||
"scripts": { | ||
"start": "gulp --gulpfile examples/gulpfile.js", | ||
"test": "mocha tests" | ||
@@ -34,3 +36,3 @@ }, | ||
"author": "", | ||
"description": "Detects JavaScript/CSS references in HTML and passes to others plugins" | ||
"description": "Detects JavaScript/CSS references in HTML and passes/assigns to others plugins" | ||
} |
11
parse.js
@@ -17,4 +17,11 @@ 'use strict'; | ||
var type = block[1], | ||
inputs = splitInputs(block[4], INPUTS[type]).map(function(input) { | ||
var type = block[1]; | ||
if (type === 'css' || type === 'style') { | ||
type = 'styles'; | ||
} else if (type === 'js' || type === 'script') { | ||
type = 'scripts'; | ||
} | ||
var inputs = splitInputs(block[4], INPUTS[type]).map(function(input) { | ||
return parseInputs(input, DIRECTORY); | ||
@@ -21,0 +28,0 @@ }); |
@@ -11,15 +11,32 @@ # gulp-assign | ||
``` | ||
└── src/ | ||
├── css/ | ||
│ ├── lib/ | ||
│ │ ├── a.css | ||
│ │ └── b.css | ||
│ ├── a.css | ||
│ └── b.css | ||
├── js/ | ||
│ ├── lib/ | ||
│ │ ├── a.js | ||
│ │ └── b.js | ||
│ ├── a.js | ||
│ └── b.js | ||
└── index.html | ||
``` | ||
```html | ||
<!-- build:styles /css/main.css --> | ||
<link rel="stylesheet" href="css/aaa.css" /> | ||
<link rel="stylesheet" href="css/bbb.css" /> | ||
<!-- build:css /css/main.css --> | ||
<link rel="stylesheet" href="css/a.css" /> | ||
<link rel="stylesheet" href="css/b.css" /> | ||
<!-- endbuild --> | ||
<!-- build:scripts:vendor /js/lib/main.js --> | ||
<script src="js/lib/aaa.js"></script> | ||
<script src="js/lib/bbb.js"></script> | ||
<!-- build:js:lib ./js/main.lib.js --> | ||
<script src="js/lib/a.js"></script> | ||
<script src="js/lib/b.js"></script> | ||
<!-- endbuild --> | ||
<!-- build:scripts /js/main.js --> | ||
<script src="js/aaa.js"></script> | ||
<script src="js/bbb.js"></script> | ||
<!-- build:js ./js/main.js --> | ||
<script src="js/a.js"></script> | ||
<script src="js/b.js"></script> | ||
<!-- endbuild --> | ||
@@ -42,5 +59,3 @@ ``` | ||
.on('error', callback) | ||
.on('end', function() { | ||
callback(null, output.original); | ||
}); | ||
.on('end', callback); | ||
}; | ||
@@ -52,7 +67,7 @@ | ||
default: streamAssignee, | ||
vendor: callbackAssignee | ||
lib: callbackAssignee | ||
} | ||
}; | ||
gulp.task('optimize', function() { | ||
gulp.task('pack', function() { | ||
return gulp.src('src/**/*.html') | ||
@@ -63,1 +78,20 @@ .pipe(assign(assignees)) | ||
``` | ||
### Results | ||
``` | ||
└── dist/ | ||
├── css/ | ||
│ └── main.css | ||
├── js/ | ||
│ ├── main.js | ||
│ └── main.lib.js | ||
└── index.html | ||
``` | ||
```html | ||
<link rel="stylesheet" href="/css/main.css" /> | ||
<script src="./js/main.lib.js"></script> | ||
<script src="./js/main.js"></script> | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30463
36
443
94
7