assets-manager
Advanced tools
Comparing version 0.3.5 to 0.3.6
@@ -260,3 +260,4 @@ 'use strict'; | ||
log: console.log, | ||
replaces: {} | ||
replaces: {}, | ||
processes: {} | ||
}, options); | ||
@@ -280,3 +281,3 @@ | ||
var promise = null; | ||
var rules = {}; | ||
var replaces = {}; | ||
@@ -286,3 +287,3 @@ if (options.replaces) { | ||
if ((0, _minimatch2.default)(target.dest, glob, { matchBase: true })) { | ||
Object.assign(rules, options.replaces[glob]); | ||
Object.assign(replaces, options.replaces[glob]); | ||
} | ||
@@ -292,8 +293,32 @@ } | ||
if (Object.keys(rules).length === 0) { | ||
if (Object.keys(replaces).length === 0) { | ||
promise = _this7.copy(target.src, target.dest, opts); | ||
} else { | ||
promise = _this7.replace(target.src, target.dest, rules, opts); | ||
promise = _this7.replace(target.src, target.dest, replaces, opts); | ||
} | ||
if (options.processes) { | ||
(function () { | ||
var processes = []; | ||
for (var _glob in options.processes) { | ||
if ((0, _minimatch2.default)(target.dest, _glob, { matchBase: true })) { | ||
processes.push(options.processes[_glob]); | ||
} | ||
} | ||
if (processes.length !== 0) { | ||
promise = promise.then(function () { | ||
return _this7.read(target.dest, opts).then(function (content) { | ||
content = content.toString(options.encoding); | ||
processes.forEach(function (process) { | ||
content = process(content, target.dest); | ||
}); | ||
return _this7.write(target.dest, content, options); | ||
}); | ||
}); | ||
} | ||
})(); | ||
} | ||
return promise.then(log(_chalk2.default.green('Copying: ') + target.src + _chalk2.default.cyan(' -> ') + target.dest)).catch(function (err) { | ||
@@ -300,0 +325,0 @@ reject('Cannot copy ' + target.src + '\'\' to \'' + target.dest + '\': ' + err.message); |
@@ -296,3 +296,4 @@ 'use strict'; | ||
cwd: _configure2.default.get('cwd'), | ||
replaces: Object.assign(_this.getConfigure('replaces'), pkg.options.replaces) | ||
replaces: Object.assign(_this.getConfigure('replaces'), pkg.options.replaces), | ||
processes: Object.assign(_this.getConfigure('processes'), pkg.options.processes) | ||
}, options)).then(resolve).catch(reject); | ||
@@ -447,2 +448,3 @@ }); | ||
this.setConfigure('replaces', this.data.replaces, {}); | ||
this.setConfigure('processes', this.data.processes, {}); | ||
this.setConfigure('dest', this.data.dest, 'assets'); | ||
@@ -449,0 +451,0 @@ this.setConfigure('path', this.data.path, '${dest}/${type}/${package}/${file}'); |
'use strict'; | ||
/*eslint no-useless-escape: "off"*/ | ||
@@ -3,0 +4,0 @@ Object.defineProperty(exports, "__esModule", { |
{ | ||
"name": "assets-manager", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "Copy packages files based on manifest file", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/amazingSurge/assets-manager", |
@@ -345,2 +345,3 @@ # assets-manager [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url] | ||
replaces: {}, | ||
processes: {}, | ||
renames: {} | ||
@@ -367,2 +368,12 @@ } | ||
#### processes | ||
It will process the content when copy to target directory. | ||
```js | ||
"processes": { | ||
"*.css": function(content) { | ||
return content.replace('foo', 'bar'); | ||
} | ||
} | ||
``` | ||
#### renames | ||
@@ -369,0 +380,0 @@ It will rename the files when copy to target directory. Regex supported. |
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
77911
1697
416