Comparing version 2.0.1 to 3.0.0
@@ -20,5 +20,7 @@ const fs = require('fs'); | ||
module.exports = function (dir, opts={}) { | ||
function premove(dir, opts={}) { | ||
let str = resolve(opts.cwd || '.', dir); | ||
return fs.existsSync(str) && walker(str); | ||
} | ||
exports.premove = premove; |
@@ -6,9 +6,7 @@ declare namespace premove { | ||
declare module 'premove' { | ||
function premove(filepath: string, options?: Partial<premove.Options>): Promise<void> | false; | ||
export = premove; | ||
export function premove(filepath: string, options?: Partial<premove.Options>): Promise<void> | false; | ||
} | ||
declare module 'premove/sync' { | ||
function premove(filepath: string, options?: Partial<premove.Options>): void | false; | ||
export = premove; | ||
export function premove(filepath: string, options?: Partial<premove.Options>): void | false; | ||
} |
{ | ||
"name": "premove", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"repository": "lukeed/premove", | ||
"description": "A tiny (201B to 247B) utility to remove items recursively", | ||
"description": "A tiny (202B to 249B) utility to remove items recursively", | ||
"module": "dist/index.mjs", | ||
@@ -15,2 +15,5 @@ "main": "dist/index.js", | ||
}, | ||
"bin": { | ||
"premove": "bin.js" | ||
}, | ||
"exports": { | ||
@@ -28,2 +31,3 @@ ".": { | ||
"*.d.ts", | ||
"bin.js", | ||
"dist", | ||
@@ -53,4 +57,4 @@ "sync" | ||
"mk-dirs": "2.1.0", | ||
"uvu": "0.2.3" | ||
"uvu": "0.3.3" | ||
} | ||
} |
# premove [![CI](https://github.com/lukeed/premove/workflows/CI/badge.svg)](https://github.com/lukeed/premove/actions) [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/premove)](https://codecov.io/gh/lukeed/premove) | ||
> A tiny (201B to 247B) utility to remove items recursively | ||
> A tiny (202B to 249B) utility to remove items recursively | ||
This is a `Promise`-based utility that recursively removes files and directories. It's effectively `rm -rf` for Node.js. | ||
This is a `Promise`-based, cross-platform utility that recursively removes files and directories. It's effectively a programmatic `rm -rf` for Node.js. There's also a [CLI](#cli) for easy, cross-platform usage. | ||
@@ -22,3 +22,3 @@ > **Notice:** Node v12.10.0 includes the `recursive` option for [`fs.rmdir`](https://nodejs.org/api/fs.html#fs_fs_rmdir_path_options_callback) and [`fs.rmdirSync`](https://nodejs.org/api/fs.html#fs_fs_rmdirsync_path_options). | ||
> **Node.js:** >= 8.x<br> | ||
> **Size (gzip):** 247 bytes<br> | ||
> **Size (gzip):** 249 bytes<br> | ||
> **Availability:** [CommonJS](https://unpkg.com/premove/dist/index.js), [ES Module](https://unpkg.com/premove/dist/index.mjs) | ||
@@ -30,3 +30,3 @@ | ||
> **Node.js:** >= 6.x<br> | ||
> **Size (gzip):** 201 bytes<br> | ||
> **Size (gzip):** 202 bytes<br> | ||
> **Availability:** [CommonJS](https://unpkg.com/premove/sync/index.js), [ES Module](https://unpkg.com/premove/sync/index.mjs) | ||
@@ -37,4 +37,4 @@ | ||
```diff | ||
-import premove from 'premove'; | ||
+import premove from 'premove/sync'; | ||
-import { premove } from 'premove'; | ||
+import { premove } from 'premove/sync'; | ||
``` | ||
@@ -45,4 +45,4 @@ | ||
```js | ||
import premove from 'premove'; | ||
import { resolve } from 'path'; | ||
import { premove } from 'premove'; | ||
@@ -68,3 +68,20 @@ // Async/await | ||
## CLI | ||
A `premove` binary is available as of v4.0.0. <br>It accepts an optional `--cwd` value and a list of paths to delete. | ||
> **Important:** By default `premove` refuses to delete: | ||
> * the [`os.homedir`](https://nodejs.org/api/os.html#os_os_homedir) | ||
> * the system root (`/`, `C:\\`, etc) | ||
> * items not contained by `--cwd` path | ||
```sh | ||
# remove "foo" and "bar" via `npx` | ||
$ npx premove foo bar | ||
# install globally, use whenever | ||
$ npm install premove -g | ||
$ premove foo bar | ||
``` | ||
## API | ||
@@ -71,0 +88,0 @@ |
@@ -14,5 +14,7 @@ const fs = require('fs'); | ||
module.exports = function (dir, opts={}) { | ||
function premove(dir, opts={}) { | ||
let str = resolve(opts.cwd || '.', dir); | ||
return fs.existsSync(str) && walker(str); | ||
} | ||
exports.premove = premove; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9694
9
123
119