@putout/operator-filesystem 4.0.1 → 5.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/README.md +7 -7
- package/lib/filesystem.js +2 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ const [dirPath] = findFile(ast, 'hello');
|
|
|
23
23
|
const filePath = createFile(dirPath, 'world.txt', 'hello world');
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
### `createDirectory(directoryPath:
|
|
26
|
+
### `createDirectory(directoryPath: DirectoryPath, name: string): DirectoryPath`
|
|
27
27
|
|
|
28
28
|
```js
|
|
29
29
|
const {operator} = require('putout');
|
|
@@ -37,7 +37,7 @@ const [dirPath] = findFile(ast, 'hello');
|
|
|
37
37
|
const newDirectoryPath = createDirectory(dirPath, 'world');
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
### `findFile(
|
|
40
|
+
### `findFile(directoryPath: DirectoryPath, name: string | string[]): (FilePath | DirectoryPath)[]`
|
|
41
41
|
|
|
42
42
|
```js
|
|
43
43
|
const {operator} = require('putout');
|
|
@@ -64,7 +64,7 @@ const {findFile} = operator;
|
|
|
64
64
|
const coupleFiles = findFile(ast, ['/home/coderaiser', '/home/coderaiser/putout']);
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
### `getParentDirectory(
|
|
67
|
+
### `getParentDirectory(path: FilePath | DirectoryPath): FilePath | null`
|
|
68
68
|
|
|
69
69
|
```js
|
|
70
70
|
const {operator} = require('putout');
|
|
@@ -83,7 +83,7 @@ dirPath === getParentDirectory(newDirectoryPath);
|
|
|
83
83
|
true;
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
### `getFilename(path: FilePath): string`
|
|
86
|
+
### `getFilename(path: FilePath | DirectoryPath): string`
|
|
87
87
|
|
|
88
88
|
```js
|
|
89
89
|
const {operator} = require('putout');
|
|
@@ -125,7 +125,7 @@ const {removeFile} = operator;
|
|
|
125
125
|
removeFile(filePath);
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
### `copyFile(
|
|
128
|
+
### `copyFile(path: FilePath | DirectoryPath, directoryPath: DirectoryPath)`
|
|
129
129
|
|
|
130
130
|
```js
|
|
131
131
|
const {operator} = require('putout');
|
|
@@ -134,7 +134,7 @@ const {moveFile, copyFile} = operator;
|
|
|
134
134
|
copyFile(filePath, dirPath);
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
### `moveFile(
|
|
137
|
+
### `moveFile(path: FilePath | DirectoryPath, directoryPath: DirectoryPath)`
|
|
138
138
|
|
|
139
139
|
```js
|
|
140
140
|
const {operator} = require('putout');
|
|
@@ -169,7 +169,7 @@ readFileContent(filePath);
|
|
|
169
169
|
'hello';
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
-
### `renameFile(
|
|
172
|
+
### `renameFile(path: FilePath | DirectoryPath, name: string)`
|
|
173
173
|
|
|
174
174
|
```js
|
|
175
175
|
const {operator} = require('putout');
|
package/lib/filesystem.js
CHANGED
|
@@ -197,7 +197,8 @@ function maybeRemoveFile(dirPath, filename) {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
const dirPathFiles = getProperty(dirPath, 'files');
|
|
200
|
-
const
|
|
200
|
+
const name = join(getFilename(dirPath), basename(filename));
|
|
201
|
+
const [fileToOverwrite] = findFile(dirPathFiles, name);
|
|
201
202
|
|
|
202
203
|
if (!fileToOverwrite)
|
|
203
204
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/operator-filesystem",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout operator adds ability to filesystem referenced variables that was not defined",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"changelog": false,
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git://github.com/coderaiser/putout.git"
|
|
14
|
+
"url": "git+https://github.com/coderaiser/putout.git"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"test": "madrun test",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"filesystem"
|
|
37
37
|
],
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@putout/engine-parser": "^
|
|
39
|
+
"@putout/engine-parser": "^11.0.1",
|
|
40
40
|
"@putout/operator-json": "^2.0.0",
|
|
41
|
-
"@putout/test": "^
|
|
42
|
-
"c8": "^
|
|
43
|
-
"eslint": "^9.0.0
|
|
44
|
-
"eslint-plugin-n": "^17.0.0
|
|
45
|
-
"eslint-plugin-putout": "^
|
|
41
|
+
"@putout/test": "^11.0.0",
|
|
42
|
+
"c8": "^10.0.0",
|
|
43
|
+
"eslint": "^9.0.0",
|
|
44
|
+
"eslint-plugin-n": "^17.0.0",
|
|
45
|
+
"eslint-plugin-putout": "^23.0.0",
|
|
46
46
|
"lerna": "^6.0.1",
|
|
47
47
|
"madrun": "^10.0.0",
|
|
48
48
|
"montag": "^1.2.1",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"supertape": "^10.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"putout": ">=
|
|
53
|
+
"putout": ">=36"
|
|
54
54
|
},
|
|
55
55
|
"license": "MIT",
|
|
56
56
|
"engines": {
|