safe-rm 1.0.8 → 2.0.0
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/.eslintignore +2 -0
- package/.eslintrc.js +8 -0
- package/.github/workflows/nodejs.yml +27 -0
- package/README.md +59 -24
- package/bin/rm.sh +373 -126
- package/package.json +26 -3
- package/sample.safe-rm.conf +39 -0
- package/test/cases.js +231 -0
- package/test/code.js +56 -0
- package/test/helper.js +173 -0
- package/test/rm.test.js +5 -0
- package/test/safe-rm-as.test.js +8 -0
- package/test/safe-rm.test.js +5 -0
- package/test/argument.sh +0 -5
- package/test/fold.sh +0 -39
- package/test/for.sh +0 -22
- package/test/nested-switch.sh +0 -72
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: build
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
strategy:
|
|
8
|
+
matrix:
|
|
9
|
+
os: [ubuntu-latest, macos-latest]
|
|
10
|
+
node-version: [20.x]
|
|
11
|
+
|
|
12
|
+
runs-on: ${{ matrix.os }}
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v1
|
|
16
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
17
|
+
uses: actions/setup-node@v1
|
|
18
|
+
with:
|
|
19
|
+
node-version: ${{ matrix.node-version }}
|
|
20
|
+
- name: npm install, build, and test
|
|
21
|
+
run: |
|
|
22
|
+
uname -a
|
|
23
|
+
npm install
|
|
24
|
+
npm run build --if-present
|
|
25
|
+
npm run test:dev
|
|
26
|
+
env:
|
|
27
|
+
CI: true
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# safe-rm
|
|
2
|
+
|
|
1
3
|
```
|
|
2
4
|
_______ _______ _______ _______ ______ __ __
|
|
3
5
|
| || _ || || | | _ | | |_| |
|
|
@@ -8,31 +10,36 @@
|
|
|
8
10
|
|_______||__| |__||___| |_______| |___| |_||_| |_|
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
[](https://github.com/kaelzhang/shell-safe-rm/actions/workflows/nodejs.yml)
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
[Safe-rm][safe-rm], a much safer replacement of [`rm`][rm] with **ALMOST FULL** features of the origin [`rm`][rm] command.
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
The project was initially developed for Mac OS X, and then tested on Linux.
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
## Features
|
|
20
|
+
- Supports both MacOS and Linux with full test coverage.
|
|
21
|
+
- Using `safe-rm`, the files or directories you choose to remove will be moved to the system Trash instead of simply deleting them. You could put them back whenever you want manually.
|
|
22
|
+
- On MacOS, `safe-rm` will use [AppleScript][applescript] to delete files or directories as much as possible to enable the built-in "put-back" capability in the system Trash bin.
|
|
23
|
+
- On Linux, it also follows the operating system's conventions for handling duplicate files in the Trash to avoid overwriting
|
|
24
|
+
- Supports Custom [configurations](#configuration).
|
|
18
25
|
|
|
19
26
|
## Supported options
|
|
20
27
|
|
|
21
|
-
For those implemented options, safe-rm will act **exactly the same** as the original `rm` command
|
|
22
|
-
|
|
23
|
-
`-i`, `--interactive`
|
|
24
|
-
|
|
25
|
-
`-f`, `--force`
|
|
28
|
+
For those implemented options, safe-rm will act **exactly the same** as the original `rm` command:
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
`-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
| Option | Brief | Description |
|
|
31
|
+
| ------ | ----- | ------------ |
|
|
32
|
+
| `-i`, `--interactive` | **Interactive** | Prompts you to confirm before removing each file |
|
|
33
|
+
| `-I`, `--interactive=once` | **Less Interactive** | Prompts only once before removing more than three files or when recursively removing directories |
|
|
34
|
+
| `-f`, `--force` | **Force** | Removes files without prompting for confirmation, ignoring nonexistent files and overriding file protections |
|
|
35
|
+
| `-r`, `-R`, `--recursive`, `--Recursive` | **Recursive** | Removes directories and their contents recursively. Required for deleting directories |
|
|
36
|
+
| `-v`, `--verbose` | **Verbose** | Displays detailed information about each file or directory being removed |
|
|
37
|
+
| `-d`, '--directory' | **Remove Empty Directories** | `safe-rm` can check and only remove empty directories specifically with this flag |
|
|
38
|
+
| `--` | **End of Options** | Used to indicate the end of options. Useful if a filename starts with a `-` |
|
|
32
39
|
|
|
33
40
|
Combined short options are also supported, such as
|
|
34
41
|
|
|
35
|
-
`-rf`, `-riv`, etc
|
|
42
|
+
`-rf`, `-riv`, `-rfv`, etc
|
|
36
43
|
|
|
37
44
|
## Usual Installation
|
|
38
45
|
|
|
@@ -46,22 +53,22 @@ and `/path/to` is where you git clone `shell-safe-rm` in your local machine.
|
|
|
46
53
|
|
|
47
54
|
## Permanent Installation
|
|
48
55
|
|
|
49
|
-
If you have NPM (
|
|
56
|
+
If you have NPM ([NodeJS](https://nodejs.org/)) installed (RECOMMENDED):
|
|
50
57
|
|
|
51
58
|
```sh
|
|
52
59
|
npm i -g safe-rm
|
|
53
60
|
```
|
|
54
61
|
|
|
55
|
-
Or
|
|
62
|
+
Or by using the source code, within the root of the current repo (not recommended, may be unstable):
|
|
56
63
|
|
|
57
64
|
```sh
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
```
|
|
65
|
+
# If you have NodeJS installed
|
|
66
|
+
npm link
|
|
61
67
|
|
|
62
|
-
|
|
68
|
+
# If you don't have NodeJS or npm installed
|
|
69
|
+
make && sudo make install
|
|
63
70
|
|
|
64
|
-
|
|
71
|
+
# For those who have no `make` command:
|
|
65
72
|
sudo sh install.sh
|
|
66
73
|
```
|
|
67
74
|
|
|
@@ -76,7 +83,7 @@ alias rm='safe-rm'
|
|
|
76
83
|
After installation and alias definition, when you execute `rm` command in the Terminal, lines of below will be printed:
|
|
77
84
|
|
|
78
85
|
```sh
|
|
79
|
-
|
|
86
|
+
$ rm
|
|
80
87
|
safe-rm
|
|
81
88
|
usage: rm [-f | -i] [-dPRrvW] file ...
|
|
82
89
|
unlink file
|
|
@@ -86,7 +93,7 @@ which helps to tell safe-rm from the original rm.
|
|
|
86
93
|
|
|
87
94
|
## Uninstall
|
|
88
95
|
|
|
89
|
-
First remove the `alias
|
|
96
|
+
First remove the `alias rm=...` line from your `~/.bashrc` file, then
|
|
90
97
|
|
|
91
98
|
```sh
|
|
92
99
|
npm uninstall -g safe-rm
|
|
@@ -103,3 +110,31 @@ Or
|
|
|
103
110
|
```sh
|
|
104
111
|
sudo sh uninstall.sh
|
|
105
112
|
```
|
|
113
|
+
|
|
114
|
+
# Advanced Sections
|
|
115
|
+
|
|
116
|
+
## Configuration
|
|
117
|
+
|
|
118
|
+
Since 2.0.0, you could create a configuration file named `.safe-rm.conf` in your HOME directory, to support
|
|
119
|
+
- defining your custom trash directory
|
|
120
|
+
- allowing `safe-rm` to permanently delete files and directories that are already in the trash
|
|
121
|
+
- disallowing `safe-rm` to use [AppleScript][applescript]
|
|
122
|
+
|
|
123
|
+
For the description of each config, you could refer to the sample file [here](./sample.safe-rm.conf)
|
|
124
|
+
|
|
125
|
+
If you want to use a custom configuration file
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
alias="SAFE_RM_CONF=/path/to/safe-rm.conf /path/to/bin/rm.sh"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Or if it is installed by npm:
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
alias="SAFE_RM_CONF=/path/to/safe-rm.conf safe-rm"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
[applescript]: https://en.wikipedia.org/wiki/AppleScript
|
|
139
|
+
[rm]: https://en.wikipedia.org/wiki/Rm_(Unix)
|
|
140
|
+
[safe-rm]: https://github.com/kaelzhang/shell-safe-rm
|