@putout/processor-filesystem 7.0.4 → 7.2.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 CHANGED
@@ -19,6 +19,18 @@ 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: false,
31
+ });
32
+ ```
33
+
22
34
  ## License
23
35
 
24
36
  MIT
package/lib/create.js ADDED
@@ -0,0 +1,42 @@
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 = ({cli = true} = {}) => {
12
+ const branch = createBranch({
13
+ cli,
14
+ });
15
+
16
+ const merge = createMerge({
17
+ cli,
18
+ });
19
+
20
+ return {
21
+ branch,
22
+ merge,
23
+ };
24
+ };
25
+
26
+ const createBranch = ({cli}) => (rawSource) => {
27
+ cli && filesystem.init(filesystemCLI);
28
+
29
+ const source = toJS(maybeFromSimple(rawSource), __filesystem);
30
+
31
+ return [{
32
+ source,
33
+ }];
34
+ };
35
+
36
+ const createMerge = ({cli}) => (rawSource, list) => {
37
+ cli && filesystem.deinit();
38
+
39
+ const [source] = list.filter(isFilesystem);
40
+
41
+ return fromJS(source, __filesystem);
42
+ };
package/lib/filesystem.js CHANGED
@@ -1,31 +1,9 @@
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.cjs';
9
- import {maybeFromSimple} from './from-simple.js';
1
+ import {create} from './create.js';
10
2
 
11
3
  export const files = [
12
4
  '.filesystem.json',
13
5
  ];
14
6
 
15
- export const branch = (rawSource) => {
16
- filesystem.init(filesystemCLI);
17
-
18
- const source = toJS(maybeFromSimple(rawSource), __filesystem);
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
+ });
@@ -0,0 +1,3 @@
1
+ import {__filesystem_name} from '@putout/operator-json';
2
+
3
+ export const isFilesystem = (source) => !source.indexOf(__filesystem_name);
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@putout/processor-filesystem",
3
- "version": "7.0.4",
3
+ "version": "7.2.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"
11
12
  },
12
13
  "release": false,
13
14
  "tag": false,
@@ -33,12 +34,12 @@
33
34
  ],
34
35
  "devDependencies": {
35
36
  "@putout/engine-processor": "*",
36
- "@putout/eslint-flat": "^3.0.0",
37
+ "@putout/eslint-flat": "^4.0.0",
37
38
  "@putout/test": "^15.0.0",
38
39
  "c8": "^10.0.0",
39
40
  "eslint": "^10.0.0-alpha.0",
40
41
  "eslint-plugin-n": "^17.0.0",
41
- "eslint-plugin-putout": "^29.0.0",
42
+ "eslint-plugin-putout": "^30.0.0",
42
43
  "madrun": "^12.0.0",
43
44
  "montag": "^1.2.1",
44
45
  "nodemon": "^3.0.1",
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- const {__filesystem_name} = require('@putout/operator-json');
4
-
5
- module.exports.isFilesystem = (source) => !source.indexOf(__filesystem_name);