@putout/plugin-nodejs 9.3.0 → 9.4.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.
@@ -9,51 +9,46 @@ const {
9
9
  getFilename,
10
10
  readFileContent,
11
11
  findFile,
12
- __filesystem,
13
12
  renameFile,
14
13
  } = operator;
15
14
 
16
- module.exports.report = ({cjs, js}) => `Rename '${cjs}' to '${js}'`;
15
+ module.exports.report = (file, {cjs, js}) => `Rename '${cjs}' to '${js}'`;
17
16
 
18
- module.exports.fix = ({path, js}) => {
19
- renameFile(path, js);
17
+ module.exports.fix = (file, {js}) => {
18
+ renameFile(file, js);
20
19
  };
21
20
 
22
- module.exports.traverse = ({push}) => ({
23
- [__filesystem]: (path) => {
24
- for (const file of findFile(path, '*.cjs')) {
25
- const packagePath = findUpPackage(file);
26
-
27
- const cjs = getFilename(file);
28
- const js = cjs.replace(/cjs$/, 'js');
29
-
30
- if (!packagePath) {
31
- push({
32
- path: file,
33
- cjs,
34
- js,
35
- });
36
- continue;
37
- }
38
-
39
- const packageContent = readFileContent(packagePath);
40
-
41
- if (!packageContent)
42
- continue;
43
-
44
- const {type} = parse(packageContent);
45
-
46
- if (type === 'module')
47
- continue;
48
-
49
- push({
50
- path: file,
21
+ module.exports.scan = (path, {push}) => {
22
+ for (const file of findFile(path, '*.cjs')) {
23
+ const packagePath = findUpPackage(file);
24
+
25
+ const cjs = getFilename(file);
26
+ const js = cjs.replace(/cjs$/, 'js');
27
+
28
+ if (!packagePath) {
29
+ push(file, {
51
30
  cjs,
52
31
  js,
53
32
  });
33
+ continue;
54
34
  }
55
- },
56
- });
35
+
36
+ const packageContent = readFileContent(packagePath);
37
+
38
+ if (!packageContent)
39
+ continue;
40
+
41
+ const {type} = parse(packageContent);
42
+
43
+ if (type === 'module')
44
+ continue;
45
+
46
+ push(file, {
47
+ cjs,
48
+ js,
49
+ });
50
+ }
51
+ };
57
52
 
58
53
  function findUpPackage(file) {
59
54
  let packageJSON;
@@ -9,45 +9,41 @@ const {
9
9
  getFilename,
10
10
  readFileContent,
11
11
  findFile,
12
- __filesystem,
13
12
  renameFile,
14
13
  } = operator;
15
14
 
16
- module.exports.report = ({mjs, js}) => `Rename '${mjs}' to '${js}'`;
15
+ module.exports.report = (file, {mjs, js}) => `Rename '${mjs}' to '${js}'`;
17
16
 
18
- module.exports.fix = ({path, js}) => {
19
- renameFile(path, js);
17
+ module.exports.fix = (file, {js}) => {
18
+ renameFile(file, js);
20
19
  };
21
20
 
22
- module.exports.traverse = ({push}) => ({
23
- [__filesystem]: (path) => {
24
- for (const file of findFile(path, '*.mjs')) {
25
- const packagePath = findUpPackage(file);
26
-
27
- if (!packagePath)
28
- continue;
29
-
30
- const packageContent = readFileContent(packagePath);
31
-
32
- if (!packageContent)
33
- continue;
34
-
35
- const {type} = parse(packageContent);
36
-
37
- if (type !== 'module')
38
- continue;
39
-
40
- const mjs = getFilename(file);
41
- const js = mjs.replace(/mjs$/, 'js');
42
-
43
- push({
44
- path: file,
45
- mjs,
46
- js,
47
- });
48
- }
49
- },
50
- });
21
+ module.exports.scan = (path, {push}) => {
22
+ for (const file of findFile(path, '*.mjs')) {
23
+ const packagePath = findUpPackage(file);
24
+
25
+ if (!packagePath)
26
+ continue;
27
+
28
+ const packageContent = readFileContent(packagePath);
29
+
30
+ if (!packageContent)
31
+ continue;
32
+
33
+ const {type} = parse(packageContent);
34
+
35
+ if (type !== 'module')
36
+ continue;
37
+
38
+ const mjs = getFilename(file);
39
+ const js = mjs.replace(/mjs$/, 'js');
40
+
41
+ push(file, {
42
+ mjs,
43
+ js,
44
+ });
45
+ }
46
+ };
51
47
 
52
48
  function findUpPackage(file) {
53
49
  let packageJSON;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-nodejs",
3
- "version": "9.3.0",
3
+ "version": "9.4.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds ability to transform code to new API of Node.js",