prod-files 0.1.1 → 0.1.2
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/index.mjs +18 -5
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -272,7 +272,7 @@ export function printDiff({ prunedSize, startTime, itemCount, originalSize }) {
|
|
|
272
272
|
/**
|
|
273
273
|
* @typedef Args
|
|
274
274
|
* @type {object}
|
|
275
|
-
* @property {string} path - Path to node_modules
|
|
275
|
+
* @property {string} [path] - Path to node_modules
|
|
276
276
|
* @property {string[]} include - New glob pattern
|
|
277
277
|
* @property {string[]} exclude - Existing glob pattern
|
|
278
278
|
* @property {boolean} help - Prints help
|
|
@@ -299,7 +299,6 @@ function handleArgs() {
|
|
|
299
299
|
noSize: { type: 'boolean', short: 'n', default: false },
|
|
300
300
|
},
|
|
301
301
|
})
|
|
302
|
-
if (!path) throw bail('Path not defined', undefined, true)
|
|
303
302
|
|
|
304
303
|
return { ...values, path }
|
|
305
304
|
} catch (err) {
|
|
@@ -644,9 +643,13 @@ export function compactPaths(paths) {
|
|
|
644
643
|
return compact
|
|
645
644
|
}
|
|
646
645
|
|
|
646
|
+
/**
|
|
647
|
+
* @typedef {Args & { path: string }} ArgsWithRequiredPath
|
|
648
|
+
*/
|
|
649
|
+
|
|
647
650
|
/**
|
|
648
651
|
* Removes unneeded files from node_modules
|
|
649
|
-
* @param {
|
|
652
|
+
* @param {ArgsWithRequiredPath} opts
|
|
650
653
|
*/
|
|
651
654
|
export async function prune(opts) {
|
|
652
655
|
const startTime = Date.now()
|
|
@@ -701,6 +704,16 @@ if (runAsScript) {
|
|
|
701
704
|
process.exit(0)
|
|
702
705
|
}
|
|
703
706
|
|
|
704
|
-
|
|
705
|
-
|
|
707
|
+
// Should have a path by now
|
|
708
|
+
if (!args.path) {
|
|
709
|
+
throw bail(
|
|
710
|
+
undefined,
|
|
711
|
+
'Path not defined. Usage: prod-files <path-to-node-modules>'
|
|
712
|
+
)
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
const argsWithPath = /** @type {ArgsWithRequiredPath} */ (args)
|
|
716
|
+
|
|
717
|
+
await validateNodeModulesPath(argsWithPath.path)
|
|
718
|
+
await prune(argsWithPath)
|
|
706
719
|
}
|