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

filemanager-webpack-plugin

Package Overview
Dependencies
Maintainers
2
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 3.0.0-alpha.3 to 3.0.0-alpha.4

11

CHANGELOG.md

@@ -5,2 +5,13 @@ # Changelog

## v3.0.0-alpha.4 (2020-10-27)
#### Bug Fixes
- run all actions in the event ([8dc5bab](https://github.com/gregnb/filemanager-webpack-plugin/commit/8dc5bab))
- fix ignore behaviour in archiver action ([30aa49a](https://github.com/gregnb/filemanager-webpack-plugin/commit/30aa49a))
#### Features
- add option to run tasks in series ([034f645](https://github.com/gregnb/filemanager-webpack-plugin/commit/034f645))
## v3.0.0-alpha.3 (2020-10-26)

@@ -7,0 +18,0 @@

132

lib/index.js

@@ -164,2 +164,7 @@ 'use strict';

}
},
runTasksInSeries: {
type: 'boolean',
default: false,
description: 'Run tasks in an action in series'
}

@@ -169,2 +174,14 @@ }

const defaultTask = async () => {};
const pExec = async (series = false, arr = [], task = defaultTask) => {
if (series) {
await arr.reduce((p, spec) => p.then(() => task(spec)), Promise.resolve(null));
return;
}
const pMap = arr.map(async spec => await task(spec));
await Promise.all(pMap);
};
/*!

@@ -244,10 +261,2 @@ * is-extglob <https://github.com/jonschlinkert/is-extglob>

const copyAction = async tasks => {
const taskMap = tasks.map(copy);
for (const task of taskMap) {
await task;
}
};
const copy = async task => {

@@ -283,30 +292,38 @@ const {

const moveAction = async input => {
for (const task of input) {
const copyAction = async (tasks, options) => {
const {
runTasksInSeries
} = options;
pExec(runTasksInSeries, tasks, async task => await copy(task));
};
const moveAction = async (tasks, options) => {
const {
runTasksInSeries
} = options;
await pExec(runTasksInSeries, tasks, async task => {
await fsExtra__default['default'].move(task.absoluteSource, task.absoluteDestination);
}
});
};
const deleteAction = async tasks => {
for (const task of tasks) {
const deleteAction = async (tasks, options) => {
const {
runTasksInSeries
} = options;
await pExec(runTasksInSeries, tasks, async task => {
await del__default['default'](task.absoluteSource);
}
});
};
const mkdirAction = async tasks => {
for (const task of tasks) {
const mkdirAction = async (tasks, options) => {
const {
runTasksInSeries
} = options;
await pExec(runTasksInSeries, tasks, async task => {
await fs__default['default'].promises.mkdir(task.absoluteSource, {
recursive: true
});
}
});
};
const archiveAction = async tasks => {
const taskMap = tasks.map(archive);
for (const task of taskMap) {
await task;
}
};
const archive = async task => {

@@ -324,5 +341,7 @@ const {

const destDir = path__default['default'].dirname(absoluteDestination);
const globOptions = Object.assign({
ignore: destFile
}, options.globOptions || {});
const ignore = (Array.isArray(options.ignore) && options.ignore || []).concat(destFile);
const archiverOptions = {
ignore,
...(options.globOptions || {})
};
await fsExtra__default['default'].ensureDir(destDir);

@@ -334,6 +353,6 @@ const output = fs__default['default'].createWriteStream(absoluteDestination);

if (isGlob(source)) {
const gOptions = { ...globOptions,
const opts = { ...archiverOptions,
cwd: context
};
await archive.glob(source, gOptions).finalize();
await archive.glob(source, opts).finalize();
} else {

@@ -343,16 +362,22 @@ const sStat = fs__default['default'].lstatSync(absoluteSource);

if (sStat.isDirectory()) {
const gOptions = { ...globOptions,
const opts = { ...archiverOptions,
cwd: absoluteSource
};
await archive.glob('**/*', gOptions).finalize();
await archive.glob('**/*', opts).finalize();
}
if (sStat.isFile()) {
const options = {
const opts = {
name: path__default['default'].basename(source)
};
await archive.file(absoluteSource, options).finalize();
await archive.file(absoluteSource, opts).finalize();
}
} // output.close()
}
};
const archiveAction = async (tasks, options) => {
const {
runTasksInSeries
} = options;
await pExec(runTasksInSeries, tasks, async task => await archive(task));
};

@@ -365,3 +390,4 @@

onEnd: []
}
},
runTasksInSeries: false
};

@@ -387,3 +413,3 @@

absoluteSource: path__default['default'].isAbsolute(source) ? source : path__default['default'].join(context, source),
destination: destination,
destination,
absoluteDestination: path__default['default'].isAbsolute(destination) ? destination : path__default['default'].join(context, destination),

@@ -408,3 +434,6 @@ toType,

async applyAction(action, actionParams) {
await action(resolvePaths(actionParams, this.context));
const opts = {
runTasksInSeries: this.options.runTasksInSeries
};
await action(resolvePaths(actionParams, this.context), opts);
}

@@ -418,18 +447,23 @@

case 'delete':
return this.applyAction(deleteAction, action);
await this.applyAction(deleteAction, action);
break;
case 'mkdir':
return this.applyAction(mkdirAction, action);
await this.applyAction(mkdirAction, action);
break;
case 'copy':
return this.applyAction(copyAction, action);
await this.applyAction(copyAction, action);
break;
case 'move':
return this.applyAction(moveAction, action);
await this.applyAction(moveAction, action);
break;
case 'archive':
return this.applyAction(archiveAction, action);
await this.applyAction(archiveAction, action);
break;
default:
return;
throw Error('Unknown action');
}

@@ -440,11 +474,9 @@ }

async execute(eventName) {
const events = this.options.events;
const {
events
} = this.options;
if (Array.isArray(events[eventName])) {
const eventsArr = events[eventName];
for (const event of eventsArr) {
await this.run(event);
}
await pExec(true, eventsArr, async event => await this.run(event));
return;

@@ -451,0 +483,0 @@ }

{
"name": "filemanager-webpack-plugin",
"version": "3.0.0-alpha.3",
"version": "3.0.0-alpha.4",
"description": "This Webpack plugin allows you to copy, archive (.zip), move, delete files and directories before and after builds",

@@ -51,5 +51,5 @@ "author": "gregnb",

"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"ava": "^3.13.0",

@@ -56,0 +56,0 @@ "fast-glob": "^3.2.4",

@@ -92,2 +92,3 @@ <div align="center">

},
runTasksInSeries: false,
});

@@ -136,3 +137,3 @@ ```

- if source is a `glob`, destination must be a directory
- if souce is a `file`, if destination is a directory, the file will be copied into the directory
- if souce is a `file` and destination is a directory, the file will be copied into the directory

@@ -220,1 +221,14 @@ ### Delete

```
## Other Options
- **runTasksInSeries** [`boolean`] - Run tasks in series. Defaults to false
For Example
```js
copy: [
{ source: 'dist/index.html', destination: 'dir1/' },
{ source: 'dir1/index.html', destination: 'dir2/' },
];
```

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