Skip to content

Commit 78591b0

Browse files
committed
fix: @putout/plugin-filesystem: convert to ESM
1 parent 419b652 commit 78591b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+315
-322
lines changed

packages/plugin-filesystem/.putout.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
{
2+
"rules": {
3+
"putout/apply-exports": ["on", {
4+
"renameFileByMask": [
5+
"report",
6+
"fix",
7+
"scan"
8+
],
9+
"createRemoveFiles": [
10+
"report",
11+
"fix",
12+
"scan"
13+
]
14+
}]
15+
},
216
"match": {
317
"*.md": {
418
"putout-config/remove-empty": "off"

packages/plugin-filesystem/lib/bundle/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
'use strict';
1+
import {basename} from 'node:path';
2+
import {operator} from 'putout';
23

3-
const {basename} = require('node:path');
4-
const {operator} = require('putout');
54
const id = (a) => a;
65

76
const {
@@ -18,8 +17,8 @@ const maybeArray = (a) => isArray(a) ? a : [a];
1817
const {entries} = Object;
1918
const {isArray} = Array;
2019

21-
module.exports.report = () => `Minify css`;
22-
module.exports.fix = (rootPath, {dist, fileGroups}) => {
20+
export const report = () => `Minify css`;
21+
export const fix = (rootPath, {dist, fileGroups}) => {
2322
const distDirectory = createDirectory(rootPath, dist);
2423

2524
for (const [name, content] of entries(fileGroups)) {
@@ -46,7 +45,7 @@ const mark = (a) => a.__putout_filesystem_processed = true;
4645
const isMarked = (a) => a.__putout_filesystem_processed;
4746
const process = (file, transform, config) => transform(readFileContent(file), config);
4847

49-
module.exports.scan = (rootPath, {push, options}) => {
48+
export const scan = (rootPath, {push, options}) => {
5049
const {
5150
transform = id,
5251
groups = [],

packages/plugin-filesystem/lib/bundle/index.spec.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
'use strict';
1+
import tryCatch from 'try-catch';
2+
import {createTest} from '@putout/test';
3+
import {minify} from './minify.spec.js';
4+
import * as plugin from './index.js';
25

3-
const tryCatch = require('try-catch');
4-
const {createTest} = require('@putout/test');
5-
6-
const {minify} = require('./minify.spec');
7-
const plugin = require('.');
8-
9-
const test = createTest(__dirname, {
6+
const test = createTest(import.meta.url, {
107
plugins: [
118
['bundle-css', plugin],
129
],

packages/plugin-filesystem/lib/bundle/minify.spec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict';
1+
import Clean from 'clean-css';
22

3-
const Clean = require('clean-css');
4-
5-
module.exports.minify = (data, config) => {
3+
export const minify = (data, config) => {
64
const {
75
styles,
86
errors,

packages/plugin-filesystem/lib/convert-filesystem-to-simple-filesystem/index.js renamed to packages/plugin-filesystem/lib/convert-filesystem-to-simple-filesystem/index.cjs

File renamed without changes.

packages/plugin-filesystem/lib/convert-filesystem-to-simple-filesystem/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.cjs';
23

3-
const {createTest} = require('@putout/test');
4-
const plugin = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['convert-filesystem-to-simple-filesystem', plugin],
97
],
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
'use strict';
1+
import {operator} from 'putout';
22

3-
const {operator} = require('putout');
43
const {__json} = operator;
54

6-
module.exports.report = () => `Convert '*.js' to '*.json'`;
5+
export const report = () => `Convert '*.js' to '*.json'`;
76

8-
module.exports.replace = () => ({
7+
export const replace = () => ({
98
'export default __object': __json,
109
'module.exports = __object': __json,
1110
});

packages/plugin-filesystem/lib/convert-js-to-json/convert/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const plugin = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['convert', plugin],
97
],
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
'use strict';
1+
import {operator} from 'putout';
2+
import * as convert from './convert/index.js';
23

3-
const {matchFiles} = require('putout').operator;
4-
const convert = require('./convert');
5-
6-
module.exports = matchFiles({
4+
const {matchFiles} = operator;
5+
const {
6+
report,
7+
fix,
8+
scan,
9+
} = matchFiles({
710
'__name.js -> __name.json': convert,
811
});
12+
13+
export {
14+
report,
15+
fix,
16+
scan,
17+
};

packages/plugin-filesystem/lib/convert-js-to-json/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const plugin = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['convert-js-to-json', plugin],
97
],

0 commit comments

Comments
 (0)