filemanager-webpack-plugin
Advanced tools
Comparing version 1.0.21 to 1.0.22
163
lib/index.js
@@ -13,119 +13,8 @@ 'use strict'; | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
var classCallCheck = function (instance, Constructor) { | ||
@@ -212,2 +101,3 @@ if (!(instance instanceof Constructor)) { | ||
var makeDir = require("make-dir"); | ||
var archiver = require("archiver"); | ||
@@ -505,2 +395,53 @@ var FileManagerPlugin = function () { | ||
case "archive": | ||
var _loop5 = function _loop5(key) { | ||
var command = { | ||
source: _this3.replaceHash(fileOptions[key].source), | ||
destination: fileOptions[key].destination | ||
}; | ||
if (!command.source || !command.destination) { | ||
if (_this3.options.verbose) { | ||
console.log(" - FileManagerPlugin: Warning - archive parameter has to be formated as follows: { source: <string>, destination: <string> }"); | ||
} | ||
return { | ||
v: void 0 | ||
}; | ||
} | ||
commandOrder.push(function () { | ||
return new Promise(function (resolve, reject) { | ||
var fileRegex = /(\*|\{+|\}+)/g; | ||
var matches = fileRegex.exec(command.source); | ||
var isGlob = matches !== null ? true : false; | ||
fs.lstat(command.source, function (sErr, sStats) { | ||
var output = fs.createWriteStream(command.destination); | ||
var archive = archiver("zip", { | ||
zlib: { level: 9 } | ||
}); | ||
archive.on("error", function (err) { | ||
reject(err); | ||
}); | ||
archive.pipe(output); | ||
if (isGlob) archive.glob(command.source);else if (sStats.isFile()) archive.file(command.source, { name: path.basename(command.source) });else if (sStats.isDirectory()) archive.directory(command.source, false); | ||
archive.finalize().then(resolve()); | ||
}); | ||
}); | ||
}); | ||
}; | ||
for (var key in fileOptions) { | ||
var _ret5 = _loop5(key); | ||
if ((typeof _ret5 === "undefined" ? "undefined" : _typeof(_ret5)) === "object") return _ret5.v; | ||
} | ||
break; | ||
default: | ||
@@ -507,0 +448,0 @@ break; |
{ | ||
"name": "filemanager-webpack-plugin", | ||
"version": "1.0.21", | ||
"description": "This Webpack plugin allows you to copy, move, delete files and directories before and after builds", | ||
"version": "1.0.22", | ||
"description": "This Webpack plugin allows you to copy, archive (.zip), move, delete files and directories before and after builds", | ||
"main": "lib/index.js", | ||
@@ -30,3 +30,3 @@ "files": [ | ||
"devDependencies": { | ||
"ava": "^0.24.0", | ||
"ava": "^0.25.0", | ||
"babel-cli": "^6.26.0", | ||
@@ -39,11 +39,12 @@ "babel-core": "^6.26.0", | ||
"delay": "^2.0.0", | ||
"eslint": "^4.5.0", | ||
"prettier": "^1.9.2", | ||
"rollup": "^0.49.1", | ||
"eslint": "^4.16.0", | ||
"prettier": "^1.10.2", | ||
"rollup": "^0.55.1", | ||
"rollup-plugin-babel": "^3.0.2", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"webpack": "^3.5.5", | ||
"webpack-dev-server": "^2.7.1" | ||
"webpack": "^3.10.0", | ||
"webpack-dev-server": "^2.11.1" | ||
}, | ||
"dependencies": { | ||
"archiver": "^2.1.1", | ||
"cpx": "^1.5.0", | ||
@@ -53,4 +54,4 @@ "fs-extra": "^5.0.0", | ||
"mv": "^2.1.1", | ||
"rimraf": "^2.6.1" | ||
"rimraf": "^2.6.2" | ||
} | ||
} |
@@ -12,3 +12,3 @@ | ||
This Webpack plugin allows you to copy, move, delete files and directories before and after builds | ||
This Webpack plugin allows you to copy, archive (.zip), move, delete files and directories before and after builds | ||
@@ -52,2 +52,7 @@ | ||
'/another/directory/' | ||
], | ||
archive: [ | ||
{ source: '/path/from', destination: '/path/to.zip' }, | ||
{ source: '/path/**/*.js', destination: '/path/to.zip' }, | ||
{ source: '/path/fromfile.txt', destination: '/path/to.zip' }, | ||
] | ||
@@ -111,1 +116,2 @@ } | ||
|**`mkdir`**|Create a directory path. Think mkdir -p |mkdir: [ <br />'/path/to/directory/', '/another/path/' <br/> ] | ||
|**`archive`**|Archive (.zip) individual files or entire directories |archive: [<br />{ source: 'dist/bundle.js', destination: '/home/web/archive.zip'<br /> }<br />] |
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
41402
5
114
6
353
+ Addedarchiver@^2.1.1
+ Addedarchiver@2.1.1(transitive)
+ Addedarchiver-utils@1.3.0(transitive)
+ Addedasync@2.6.4(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@1.2.3(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedbuffer-alloc@1.2.0(transitive)
+ Addedbuffer-alloc-unsafe@1.1.0(transitive)
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedbuffer-fill@1.0.0(transitive)
+ Addedcompress-commons@1.2.2(transitive)
+ Addedcrc@3.8.0(transitive)
+ Addedcrc32-stream@2.0.0(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedlazystream@1.0.1(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedshell-quote@1.8.1(transitive)
+ Addedtar-stream@1.6.2(transitive)
+ Addedto-buffer@1.1.1(transitive)
+ Addedxtend@4.0.2(transitive)
+ Addedzip-stream@1.2.0(transitive)
- Removedshell-quote@1.8.2(transitive)
Updatedrimraf@^2.6.2