@putout/processor-filesystem 7.1.0 → 7.3.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 +13 -0
- package/lib/create.js +49 -0
- package/lib/filesystem.js +5 -26
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -19,6 +19,19 @@ npm i @putout/processor-filesystem -D
|
|
|
19
19
|
}
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
## API
|
|
23
|
+
|
|
24
|
+
### `create(options)`
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
import {create} from '@putout/process-filesystem/create'
|
|
28
|
+
|
|
29
|
+
const {branch, merge} = create({
|
|
30
|
+
cli: true,
|
|
31
|
+
maybeSimple: true,
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
22
35
|
## License
|
|
23
36
|
|
|
24
37
|
MIT
|
package/lib/create.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as filesystemCLI from '@putout/cli-filesystem';
|
|
2
|
+
import * as filesystem from '@putout/operator-filesystem';
|
|
3
|
+
import {
|
|
4
|
+
fromJS,
|
|
5
|
+
toJS,
|
|
6
|
+
__filesystem,
|
|
7
|
+
} from '@putout/operator-json';
|
|
8
|
+
import {isFilesystem} from './is-filesystem.js';
|
|
9
|
+
import {maybeFromSimple} from './from-simple.js';
|
|
10
|
+
|
|
11
|
+
export const create = (overrides = {}) => {
|
|
12
|
+
const {cli = true, maybeSimple = true} = overrides;
|
|
13
|
+
const branch = createBranch({
|
|
14
|
+
cli,
|
|
15
|
+
maybeSimple,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const merge = createMerge({
|
|
19
|
+
cli,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
branch,
|
|
24
|
+
merge,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const createBranch = ({cli, maybeSimple}) => (rawSource) => {
|
|
29
|
+
cli && filesystem.init(filesystemCLI);
|
|
30
|
+
|
|
31
|
+
if (!maybeSimple)
|
|
32
|
+
return [{
|
|
33
|
+
source: toJS(rawSource, __filesystem),
|
|
34
|
+
}];
|
|
35
|
+
|
|
36
|
+
const source = toJS(maybeFromSimple(rawSource), __filesystem);
|
|
37
|
+
|
|
38
|
+
return [{
|
|
39
|
+
source,
|
|
40
|
+
}];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const createMerge = ({cli}) => (rawSource, list) => {
|
|
44
|
+
cli && filesystem.deinit();
|
|
45
|
+
|
|
46
|
+
const [source] = list.filter(isFilesystem);
|
|
47
|
+
|
|
48
|
+
return fromJS(source, __filesystem);
|
|
49
|
+
};
|
package/lib/filesystem.js
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as filesystem from '@putout/operator-filesystem';
|
|
3
|
-
import {
|
|
4
|
-
fromJS,
|
|
5
|
-
toJS,
|
|
6
|
-
__filesystem,
|
|
7
|
-
} from '@putout/operator-json';
|
|
8
|
-
import {isFilesystem} from './is-filesystem.js';
|
|
9
|
-
import {maybeFromSimple} from './from-simple.js';
|
|
1
|
+
import {create} from '#create';
|
|
10
2
|
|
|
11
3
|
export const files = [
|
|
12
4
|
'.filesystem.json',
|
|
13
5
|
];
|
|
14
6
|
|
|
15
|
-
export const branch = (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return [{
|
|
21
|
-
source,
|
|
22
|
-
}];
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const merge = (rawSource, list) => {
|
|
26
|
-
filesystem.deinit();
|
|
27
|
-
|
|
28
|
-
const [source] = list.filter(isFilesystem);
|
|
29
|
-
|
|
30
|
-
return fromJS(source, __filesystem);
|
|
31
|
-
};
|
|
7
|
+
export const {branch, merge} = create({
|
|
8
|
+
cli: true,
|
|
9
|
+
maybeSimple: true,
|
|
10
|
+
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/processor-filesystem",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout processor adds ability to lint filesystem",
|
|
7
7
|
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/processor-filesystem#readme",
|
|
8
8
|
"main": "lib/filesystem.js",
|
|
9
9
|
"exports": {
|
|
10
|
-
".": "./lib/filesystem.js"
|
|
10
|
+
".": "./lib/filesystem.js",
|
|
11
|
+
"./create": "./lib/create.js"
|
|
12
|
+
},
|
|
13
|
+
"imports": {
|
|
14
|
+
"#create": "./lib/create.js"
|
|
11
15
|
},
|
|
12
16
|
"release": false,
|
|
13
17
|
"tag": false,
|
|
@@ -33,12 +37,12 @@
|
|
|
33
37
|
],
|
|
34
38
|
"devDependencies": {
|
|
35
39
|
"@putout/engine-processor": "*",
|
|
36
|
-
"@putout/eslint-flat": "^
|
|
40
|
+
"@putout/eslint-flat": "^4.0.0",
|
|
37
41
|
"@putout/test": "^15.0.0",
|
|
38
42
|
"c8": "^10.0.0",
|
|
39
43
|
"eslint": "^10.0.0-alpha.0",
|
|
40
44
|
"eslint-plugin-n": "^17.0.0",
|
|
41
|
-
"eslint-plugin-putout": "^
|
|
45
|
+
"eslint-plugin-putout": "^30.0.0",
|
|
42
46
|
"madrun": "^12.0.0",
|
|
43
47
|
"montag": "^1.2.1",
|
|
44
48
|
"nodemon": "^3.0.1",
|