Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filemanager-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filemanager-webpack-plugin - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

newfile.js

283

lib/index.js
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
var cpr = require('cpr');
var rimraf = require('rimraf');
var mv = require('mv');
var makeDir = require('make-dir');
var FileManagerPlugin = function () {
function FileManagerPlugin(options) {
classCallCheck(this, FileManagerPlugin);
_classCallCheck(this, FileManagerPlugin);
this.options = this.setOptions(options);

@@ -224,3 +31,3 @@ this.isWin = /^win/.test(process.platform);

createClass(FileManagerPlugin, [{
_createClass(FileManagerPlugin, [{
key: 'setOptions',

@@ -231,2 +38,3 @@ value: function setOptions(userOptions) {

verbose: false,
moveWithMkdirp: false,
onStart: {},

@@ -257,6 +65,6 @@ onEnd: {}

this.options[stage].map(function (opts) {
return operationList.push.apply(operationList, toConsumableArray(_this.parseFileOptions(opts, true)));
return operationList.push.apply(operationList, _toConsumableArray(_this.parseFileOptions(opts, true)));
});
} else {
operationList.push.apply(operationList, toConsumableArray(this.parseFileOptions(this.options[stage])));
operationList.push.apply(operationList, _toConsumableArray(this.parseFileOptions(this.options[stage])));
}

@@ -294,5 +102,10 @@

if (!command.source || !command.destination) return {
if (!command.source || !command.destination) {
if (_this2.options.verbose) {
console.log(' - FileManagerPlugin: Warning - copy parameter has to be formated as follows: { source: <string>, destination: <string> }');
}
return {
v: void 0
};
}

@@ -307,2 +120,5 @@ commandOrder.push(function () {

cpr(command.source, command.destination, _this2.cprOptions, function (err, files) {
if (err && _this2.options.verbose) {
console.log(' - FileManagerPlugin: Error - copy failed', err);
}

@@ -332,9 +148,27 @@ if (_this2.options.verbose) {

if (!command.source || !command.destination) return {
if (!command.source || !command.destination) {
if (_this2.options.verbose) {
console.log(' - FileManagerPlugin: Warning - move parameter has to be formated as follows: { source: <string>, destination: <string> }');
}
return {
v: void 0
};
}
commandOrder.push(function () {
return new Promise(function (resolve, reject) {
mv(command.source, command.destination, function (err) {
if (_this2.options.verbose) {
console.log(' - FileManagerPlugin: Start move source: ' + command.source + ' to destination: ' + command.destination);
}
mv(command.source, command.destination, { mkdirp: _this2.options.moveWithMkdirp }, function (err) {
if (err && _this2.options.verbose) {
console.log(' - FileManagerPlugin: Error - move failed', err);
}
if (_this2.options.verbose) {
console.log(' - FileManagerPlugin: Finished move source: ' + command.source + ' to destination: ' + command.destination);
}
resolve(err);

@@ -366,2 +200,9 @@ });

if (typeof path !== 'string') {
if (_this2.options.verbose) {
console.log(' - FileManagerPlugin: Warning - delete parameter has to be type of string. Process canceled.');
}
return;
}
rimraf(path, {}, function (response) {

@@ -383,2 +224,33 @@ if (_this2.options.verbose && response === null) {

case 'mkdir':
var _loop4 = function _loop4(key) {
var path = fileOptions[key];
if (_this2.options.verbose) {
console.log(' - FileManagerPlugin: Creating path ' + path);
}
if (typeof path !== 'string') {
if (_this2.options.verbose) {
console.log(' - FileManagerPlugin: Warning - mkdir parameter has to be type of string. Process canceled.');
}
return {
v: void 0
};
}
commandOrder.push(function () {
return makeDir(path);
});
};
for (var key in fileOptions) {
var _ret4 = _loop4(key);
if ((typeof _ret4 === 'undefined' ? 'undefined' : _typeof(_ret4)) === "object") return _ret4.v;
}
break;
default:

@@ -410,2 +282,3 @@ break;

}]);
return FileManagerPlugin;

@@ -412,0 +285,0 @@ }();

{
"name": "filemanager-webpack-plugin",
"version": "1.0.11",
"version": "1.0.12",
"description": "This Webpack plugin allows you to copy, move, delete files and directories before and after builds",

@@ -42,2 +42,3 @@ "main": "lib/index.js",

"cpr": "^2.2.0",
"make-dir": "^1.1.0",
"mv": "^2.1.1",

@@ -44,0 +45,0 @@ "rimraf": "^2.6.1"

@@ -43,2 +43,6 @@

'/path/to/directory/'
],
mkdir: [
'/path/to/directory/',
'/another/directory/'
]

@@ -101,1 +105,2 @@ }

|**`move`**|Move individual files or entire directories. |move: <br /> { source: 'dist/bundle.js', destination: '/home/web/js/'<br /> }
|**`mkdir`**|Create a directory path. Think mkdir -p |mkdir: [ <br />'/path/to/directory/', '/another/path/' <br/> ]
const cpr = require('cpr');
const rimraf = require('rimraf');
const mv = require('mv');
const makeDir = require('make-dir');

@@ -25,2 +26,3 @@ class FileManagerPlugin {

verbose: false,
moveWithMkdirp: false,
onStart: {},

@@ -84,4 +86,8 @@ onEnd: {}

if (!command.source || !command.destination)
if (!command.source || !command.destination) {
if (this.options.verbose) {
console.log(' - FileManagerPlugin: Warning - copy parameter has to be formated as follows: { source: <string>, destination: <string> }');
}
return;
}

@@ -96,2 +102,5 @@

cpr(command.source, command.destination, this.cprOptions, (err, files) => {
if (err && this.options.verbose) {
console.log(' - FileManagerPlugin: Error - copy failed', err);
}

@@ -119,7 +128,24 @@ if (this.options.verbose) {

if (!command.source || !command.destination)
if (!command.source || !command.destination) {
if (this.options.verbose) {
console.log(' - FileManagerPlugin: Warning - move parameter has to be formated as follows: { source: <string>, destination: <string> }');
}
return;
}
commandOrder.push(() => new Promise((resolve, reject) => {
mv(command.source, command.destination, (err) => {
if (this.options.verbose) {
console.log(` - FileManagerPlugin: Start move source: ${command.source} to destination: ${command.destination}`)
}
mv(command.source, command.destination, { mkdirp: this.options.moveWithMkdirp }, (err) => {
if (err && this.options.verbose) {
console.log(' - FileManagerPlugin: Error - move failed', err);
}
if (this.options.verbose) {
console.log(` - FileManagerPlugin: Finished move source: ${command.source} to destination: ${command.destination}`)
}
resolve(err);

@@ -144,2 +170,9 @@ });

}
if (typeof path !== 'string') {
if (this.options.verbose) {
console.log(' - FileManagerPlugin: Warning - delete parameter has to be type of string. Process canceled.');
}
return;
}

@@ -158,3 +191,25 @@ rimraf(path, { }, (response) => {

break;
case 'mkdir':
for(let key in fileOptions) {
const path = fileOptions[key];
if (this.options.verbose) {
console.log(` - FileManagerPlugin: Creating path ${path}`)
}
if (typeof path !== 'string') {
if (this.options.verbose) {
console.log(' - FileManagerPlugin: Warning - mkdir parameter has to be type of string. Process canceled.');
}
return;
}
commandOrder.push(() => makeDir(path));
}
break;
default:

@@ -161,0 +216,0 @@ break;

@@ -26,3 +26,3 @@ const path = require('path');

{ source: "./dist/bundle.js", destination: "./newfile.js" }
]
],
}

@@ -29,0 +29,0 @@ /*

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc