@rollup-extras/plugin-clean 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3,17 +3,23 @@
3
3
  var fs = require('fs/promises');
4
4
  var path = require('path');
5
5
  var logger = require('@niceties/logger');
6
+ var options = require('@rollup-extras/utils/options');
6
7
 
7
8
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
9
 
9
10
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
10
11
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
11
12
 
12
- function index (options = {}) {
13
+ function index (options$1 = {}) {
13
14
  const deleted = new Map();
14
- const normailizedOptions = normalizeOptions(options);
15
- const { pluginName, deleteOnce, verbose, outputPlugin } = normailizedOptions;
16
- let { targets } = normailizedOptions;
15
+ const normalizedOptions = options.getOptions(options$1, {
16
+ pluginName: '@rollup-extras/plugin-clean',
17
+ deleteOnce: true,
18
+ verbose: false,
19
+ outputPlugin: true
20
+ }, 'targets');
21
+ const { pluginName, deleteOnce, verbose, outputPlugin } = normalizedOptions;
22
+ let { targets } = normalizedOptions;
17
23
  const pluginInstance = {
18
24
  name: pluginName
19
25
  };
@@ -75,29 +81,6 @@ function normalizeSlash(dir) {
75
81
  return `${dir.substring(0, dir.length - 1)}`;
76
82
  }
77
83
  return dir;
78
- }
79
- function normalizeOptions(userOptions) {
80
- var _a, _b, _c, _d;
81
- const options = {
82
- pluginName: (_a = userOptions.pluginName) !== null && _a !== void 0 ? _a : '@rollup-extras/plugin-clean',
83
- deleteOnce: (_b = userOptions.deleteOnce) !== null && _b !== void 0 ? _b : true,
84
- verbose: (_c = userOptions.verbose) !== null && _c !== void 0 ? _c : false,
85
- outputPlugin: (_d = userOptions.outputPlugin) !== null && _d !== void 0 ? _d : true,
86
- targets: getTargets(userOptions)
87
- };
88
- return options;
89
- }
90
- function getTargets(userOptions) {
91
- if (typeof userOptions === 'string') {
92
- return [userOptions];
93
- }
94
- if (Array.isArray(userOptions)) {
95
- return userOptions;
96
- }
97
- if (typeof userOptions === 'object') {
98
- return 'targets' in userOptions ? getTargets(userOptions.targets) : undefined;
99
- }
100
- return [];
101
84
  }
102
85
 
103
86
  module.exports = index;
package/dist/index.mjs CHANGED
@@ -1,12 +1,18 @@
1
1
  import fs from 'fs/promises';
2
2
  import path from 'path';
3
3
  import { createLogger } from '@niceties/logger';
4
+ import { getOptions } from '@rollup-extras/utils/options';
4
5
 
5
6
  function index (options = {}) {
6
7
  const deleted = new Map();
7
- const normailizedOptions = normalizeOptions(options);
8
- const { pluginName, deleteOnce, verbose, outputPlugin } = normailizedOptions;
9
- let { targets } = normailizedOptions;
8
+ const normalizedOptions = getOptions(options, {
9
+ pluginName: '@rollup-extras/plugin-clean',
10
+ deleteOnce: true,
11
+ verbose: false,
12
+ outputPlugin: true
13
+ }, 'targets');
14
+ const { pluginName, deleteOnce, verbose, outputPlugin } = normalizedOptions;
15
+ let { targets } = normalizedOptions;
10
16
  const pluginInstance = {
11
17
  name: pluginName
12
18
  };
@@ -68,29 +74,6 @@ function normalizeSlash(dir) {
68
74
  return `${dir.substring(0, dir.length - 1)}`;
69
75
  }
70
76
  return dir;
71
- }
72
- function normalizeOptions(userOptions) {
73
- var _a, _b, _c, _d;
74
- const options = {
75
- pluginName: (_a = userOptions.pluginName) !== null && _a !== void 0 ? _a : '@rollup-extras/plugin-clean',
76
- deleteOnce: (_b = userOptions.deleteOnce) !== null && _b !== void 0 ? _b : true,
77
- verbose: (_c = userOptions.verbose) !== null && _c !== void 0 ? _c : false,
78
- outputPlugin: (_d = userOptions.outputPlugin) !== null && _d !== void 0 ? _d : true,
79
- targets: getTargets(userOptions)
80
- };
81
- return options;
82
- }
83
- function getTargets(userOptions) {
84
- if (typeof userOptions === 'string') {
85
- return [userOptions];
86
- }
87
- if (Array.isArray(userOptions)) {
88
- return userOptions;
89
- }
90
- if (typeof userOptions === 'object') {
91
- return 'targets' in userOptions ? getTargets(userOptions.targets) : undefined;
92
- }
93
- return [];
94
77
  }
95
78
 
96
79
  export { index as default };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.2",
2
+ "version": "1.0.3",
3
3
  "license": "MIT",
4
4
  "name": "@rollup-extras/plugin-clean",
5
5
  "author": {
@@ -30,19 +30,19 @@
30
30
  "url": "https://github.com/kshutkin/rollup-extras/issues"
31
31
  },
32
32
  "homepage": "https://github.com/kshutkin/rollup-extras/plugin-clean/README.md",
33
+ "readme": "README.md",
34
+ "description": "Rollup plugin to clean a directory during build.",
33
35
  "keywords": [
34
- "rollup-plugin"
36
+ "rollup-plugin",
37
+ "clean"
35
38
  ],
36
39
  "scripts": {
37
- "build": "rimraf ./dist && rollup -c",
38
- "dev": "rimraf ./dist && rollup -c -w",
40
+ "build": "pkgbld",
39
41
  "test": "jest --collectCoverage",
40
42
  "lint": "eslint ./src",
41
43
  "semantic-release": "npx semantic-release"
42
44
  },
43
45
  "devDependencies": {
44
- "@rollup/plugin-commonjs": "21.0.1",
45
- "@rollup/plugin-node-resolve": "13.0.6",
46
46
  "@semantic-release/changelog": "6.0.1",
47
47
  "@semantic-release/commit-analyzer": "9.0.1",
48
48
  "@semantic-release/git": "10.0.1",
@@ -54,24 +54,18 @@
54
54
  "conventional-changelog-angular": "5.0.13",
55
55
  "eslint": "8.1.0",
56
56
  "jest": "27.3.1",
57
- "lodash": "4.17.21",
58
- "rimraf": "3.0.2",
59
- "is-builtin-module": "3.1.0",
60
- "rollup": "2.60.1",
61
- "rollup-plugin-terser": "7.0.2",
62
- "rollup-plugin-typescript2": "0.31.1",
63
- "rollup-plugin-preprocess": "0.0.4",
64
57
  "semantic-release": "18.0.0",
65
58
  "semantic-release-monorepo": "7.0.5",
66
59
  "ts-jest": "27.0.7",
67
- "typescript": "4.4.x",
68
- "update-monorepo-package-json": "0.1.6"
60
+ "typescript": "4.5.x",
61
+ "update-monorepo-package-json": "0.2.0",
62
+ "pkgbld": "1.1.1"
69
63
  },
70
64
  "peerDependencies": {
71
65
  "rollup": "^2.60.2"
72
66
  },
73
67
  "dependencies": {
74
- "@niceties/logger": "^1.0.4"
75
- },
76
- "readme": "ERROR: No README data found!"
68
+ "@niceties/logger": "^1.0.4",
69
+ "@rollup-extras/utils": "^1.0.1"
70
+ }
77
71
  }