Skip to content

Commit

Permalink
Switch to modules
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Jun 24, 2021
1 parent 0f598eb commit ab86f31
Show file tree
Hide file tree
Showing 26 changed files with 74 additions and 81 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

1 change: 0 additions & 1 deletion .browserslistrc

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tests

on:
push:
branches: [master]
branches: master
pull_request:
branches: [master]
branches: master

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install pretty-quick --staged
# npx --no-install pretty-quick --staged
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ yarn add filemanager-webpack-plugin --dev

const FileManagerPlugin = require('filemanager-webpack-plugin');

module.exports = {
export default {
// ...rest of the config
plugins: [
new FileManagerPlugin({
events: {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"bugs": "https://github.com/gregnb/filemanager-webpack-plugin/issues",
"homepage": "https://github.com/gregnb/filemanager-webpack-plugin#readme",
"main": "lib/index.js",
"type": "module",
"engines": {
"node": ">= 10.13"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"contributors": [
"sibiraj-s"
Expand Down
File renamed without changes.
6 changes: 1 addition & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
Expand All @@ -10,14 +9,11 @@ export default {
include: 'node_modules/**',
}),
json(),
babel({
babelHelpers: 'bundled',
}),
nodeResolve({
preferBuiltins: true,
}),
],
external: ['archiver', 'cpy', 'del', 'schema-utils', 'fs', 'path', 'fs-extra'],
external: ['archiver', 'cpy', 'del', 'fs-extra', 'is-glob', 'schema-utils', 'fs', 'path'],
output: {
file: 'lib/index.js',
format: 'cjs',
Expand Down
7 changes: 3 additions & 4 deletions src/actions/archive.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import fs from 'fs';
import path from 'path';

import fs from 'node:fs';
import path from 'node:path';
import archiver from 'archiver';
import isGlob from 'is-glob';
import fsExtra from 'fs-extra';

import pExec from '../utils/p-exec';
import pExec from '../utils/p-exec.js';

const archive = async (task, { logger }) => {
const { source, absoluteSource, absoluteDestination, options = {}, context } = task;
Expand Down
7 changes: 3 additions & 4 deletions src/actions/copy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import fs from 'fs';
import path from 'path';

import fs from 'node:fs';
import path from 'node:path';
import fsExtra from 'fs-extra';
import cpy from 'cpy';
import isGlob from 'is-glob';

import pExec from '../utils/p-exec';
import pExec from '../utils/p-exec.js';

const fsExtraDefaultOptions = {
preserveTimestamps: true,
Expand Down
2 changes: 1 addition & 1 deletion src/actions/delete.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import del from 'del';

import pExec from '../utils/p-exec';
import pExec from '../utils/p-exec.js';

const deleteAction = async (tasks, taskOptions) => {
const { runTasksInSeries, logger } = taskOptions;
Expand Down
10 changes: 5 additions & 5 deletions src/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { default as copyAction } from './copy';
export { default as moveAction } from './move';
export { default as deleteAction } from './delete';
export { default as mkdirAction } from './mkdir';
export { default as archiveAction } from './archive';
export { default as copyAction } from './copy.js';
export { default as moveAction } from './move.js';
export { default as deleteAction } from './delete.js';
export { default as mkdirAction } from './mkdir.js';
export { default as archiveAction } from './archive.js';
4 changes: 2 additions & 2 deletions src/actions/mkdir.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import fs from 'node:fs';

import pExec from '../utils/p-exec';
import pExec from '../utils/p-exec.js';

const mkdirAction = async (tasks, options) => {
const { runTasksInSeries, logger } = options;
Expand Down
2 changes: 1 addition & 1 deletion src/actions/move.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fsExtra from 'fs-extra';

import pExec from '../utils/p-exec';
import pExec from '../utils/p-exec.js';

const moveAction = async (tasks, options) => {
const { runTasksInSeries, logger } = options;
Expand Down
9 changes: 4 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import path from 'path';

import path from 'node:path';
import { validate } from 'schema-utils';

import optionsSchema from './options-schema';
import pExec from './utils/p-exec';
import { copyAction, moveAction, mkdirAction, archiveAction, deleteAction } from './actions';
import optionsSchema from './options-schema.js';
import pExec from './utils/p-exec.js';
import { copyAction, moveAction, mkdirAction, archiveAction, deleteAction } from './actions/index.js';

const PLUGIN_NAME = 'FileManagerPlugin';

Expand Down
8 changes: 4 additions & 4 deletions tests/archive.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import test from 'ava';
import del from 'del';
import JSZip from 'jszip';

import compile from './utils/compile';
import getCompiler from './utils/getCompiler';
import tempy from './utils/tempy';
import compile from './utils/compile.js';
import getCompiler from './utils/getCompiler.js';
import tempy from './utils/tempy.js';

import FileManagerPlugin from '../lib';
import FileManagerPlugin from '../src/index.js';

const zipHasFile = async (zipPath, fileName) => {
const data = await fs.promises.readFile(zipPath);
Expand Down
8 changes: 4 additions & 4 deletions tests/copy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { basename, join, posix } from 'path';
import test from 'ava';
import del from 'del';

import compile from './utils/compile';
import getCompiler from './utils/getCompiler';
import compile from './utils/compile.js';
import getCompiler from './utils/getCompiler.js';
import tempy from './utils/tempy.js';

import FileManagerPlugin from '../lib';
import tempy from './utils/tempy';
import FileManagerPlugin from '../src/index.js';

test.beforeEach(async (t) => {
t.context.tmpdir = await tempy.dir({ suffix: 'copy-action' });
Expand Down
8 changes: 4 additions & 4 deletions tests/delete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { existsSync } from 'fs';
import test from 'ava';
import del from 'del';

import compile from './utils/compile';
import getCompiler from './utils/getCompiler';
import tempy from './utils/tempy';
import compile from './utils/compile.js';
import getCompiler from './utils/getCompiler.js';
import tempy from './utils/tempy.js';

import FileManagerPlugin from '../lib';
import FileManagerPlugin from '../src/index.js';

test.beforeEach(async (t) => {
t.context.tmpdir = await tempy.dir({ suffix: 'delete-action' });
Expand Down
8 changes: 4 additions & 4 deletions tests/execution-order.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { join, relative } from 'path';
import test from 'ava';
import del from 'del';

import compile from './utils/compile';
import getCompiler from './utils/getCompiler';
import tempy from './utils/tempy';
import compile from './utils/compile.js';
import getCompiler from './utils/getCompiler.js';
import tempy from './utils/tempy.js';

import FileManagerPlugin from '../lib';
import FileManagerPlugin from '../src/index.js';

test.beforeEach(async (t) => {
t.context.tmpdir = await tempy.dir({ suffix: 'execution-order' });
Expand Down
8 changes: 4 additions & 4 deletions tests/mkdir.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { existsSync } from 'fs';
import test from 'ava';
import del from 'del';

import compile from './utils/compile';
import getCompiler from './utils/getCompiler';
import tempy from './utils/tempy';
import compile from './utils/compile.js';
import getCompiler from './utils/getCompiler.js';
import tempy from './utils/tempy.js';

import FileManagerPlugin from '../lib';
import FileManagerPlugin from '../src/index.js';

test.beforeEach(async (t) => {
t.context.tmpdir = await tempy.dir({ suffix: 'mkdir-action' });
Expand Down
8 changes: 4 additions & 4 deletions tests/move.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { join, relative, basename } from 'path';
import test from 'ava';
import del from 'del';

import compile from './utils/compile';
import getCompiler from './utils/getCompiler';
import tempy from './utils/tempy';
import compile from './utils/compile.js';
import getCompiler from './utils/getCompiler.js';
import tempy from './utils/tempy.js';

import FileManagerPlugin from '../lib';
import FileManagerPlugin from '../src/index.js';
import { existsSync } from 'fs';

test.beforeEach(async (t) => {
Expand Down
8 changes: 4 additions & 4 deletions tests/multi-actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { existsSync } from 'fs';
import test from 'ava';
import del from 'del';

import compile from './utils/compile';
import getCompiler from './utils/getCompiler';
import tempy from './utils/tempy';
import compile from './utils/compile.js';
import getCompiler from './utils/getCompiler.js';
import tempy from './utils/tempy.js';

import FileManagerPlugin from '../lib';
import FileManagerPlugin from '../src/index.js';

test.beforeEach(async (t) => {
t.context.tmpdir = await tempy.dir({ suffix: 'multi-action' });
Expand Down
15 changes: 7 additions & 8 deletions tests/other-options.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { join } from 'path';

import { join } from 'node:path';
import test from 'ava';
import del from 'del';
import { existsSync } from 'fs';

import compile from './utils/compile';
import getCompiler from './utils/getCompiler';
import getFixtruesDir from './utils/getFixturesDir';
import tempy from './utils/tempy';
import compile from './utils/compile.js';
import getCompiler from './utils/getCompiler.js';
import getFixtruesDir from './utils/getFixturesDir.js';
import tempy from './utils/tempy.js';

import FileManagerPlugin from '../lib';
import { existsSync } from 'fs';
import FileManagerPlugin from '../src/index.js';

const fixturesDir = getFixtruesDir();

Expand Down
4 changes: 2 additions & 2 deletions tests/utils/getCompiler.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import path from 'node:path';
import webpack from 'webpack';
import HTMLPlugin from 'html-webpack-plugin';

import getFixtruesDir from './getFixturesDir';
import getFixtruesDir from './getFixturesDir.js';

const fixturesDir = getFixtruesDir();

Expand Down
5 changes: 4 additions & 1 deletion tests/utils/getFixturesDir.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import path from 'path';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const getFixtruesDir = () => {
return path.resolve(__dirname, '..', 'fixtures');
Expand Down
12 changes: 6 additions & 6 deletions tests/utils/tempy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import fs from 'fs';
import crypto from 'crypto';
import path from 'node:path';
import fs from 'node:fs/promises';
import crypto from 'node:crypto';

import getFixtruesDir from './getFixturesDir';
import getFixtruesDir from './getFixturesDir.js';

const fixturesDir = getFixtruesDir();

Expand All @@ -12,13 +12,13 @@ const getDirName = (last = '') => `dir-${getRandomId()}${last}`;
const getFileName = (last = '') => `file-${getRandomId()}${last}`;

const dir = async ({ root = fixturesDir, suffix = 'random' }) => {
const tmpDir = await fs.promises.mkdtemp(path.join(root, `tmp-${suffix}-`));
const tmpDir = await fs.mkdtemp(path.join(root, `tmp-${suffix}-`));
return tmpDir;
};

const file = async (dir, fileName = getFileName()) => {
const filePath = path.join(dir, fileName);
await fs.promises.writeFile(filePath, 'lorem-ipsum', 'utf-8');
await fs.writeFile(filePath, 'lorem-ipsum', 'utf-8');
return filePath;
};

Expand Down

0 comments on commit ab86f31

Please sign in to comment.