Skip to content

Commit c2404df

Browse files
committed
feature: @cloudcmd/formatify: migrate to ESM
1 parent 80bfece commit c2404df

7 files changed

Lines changed: 24 additions & 39 deletions

File tree

.madrun.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
'use strict';
1+
import {run} from 'madrun';
22

3-
const {run} = require('madrun');
4-
5-
module.exports = {
3+
export default {
64
'lint': () => 'putout .',
75
'fix:lint': () => run('lint', '--fix'),
8-
'report': () => 'c8 report --reporter=text-lcov | coveralls',
6+
'report': () => 'c8 report --reporter=lcov',
97
'coverage': () => 'c8 npm test',
108
'test': () => 'tape test/*.js',
119
'watch:coverage': () => run('watcher', 'npm run coverage'),

eslint.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
1+
import {safeAlign} from 'eslint-plugin-putout';
22

3-
const {safeAlign} = require('eslint-plugin-putout');
4-
5-
module.exports = safeAlign;
3+
export default safeAlign;

lib/formatify.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import format from 'format-io';
2+
import shortdate from 'shortdate';
23

3-
const format = require('format-io');
4-
const shortdate = require('shortdate');
5-
6-
module.exports = (files) => {
4+
export default (files) => {
75
check(files);
86

97
return files

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@cloudcmd/formatify",
33
"version": "2.0.1",
4-
"type": "commonjs",
4+
"type": "module",
55
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
66
"description": "format directory content",
77
"homepage": "http://github.com/cloudcmd/formatify",

test/fixture-raw.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
'use strict';
2-
31
const date = new Date('2017-01-12T09:01:35.288Z');
42

5-
module.exports.sortifyRaw = {
3+
export const sortifyRaw = {
64
name: 'sortify.js',
75
size: 3538,
86
date,
97
owner: 0,
108
mode: 33_204,
119
};
1210

13-
module.exports.testRaw = {
11+
export const testRaw = {
1412
name: 'test',
1513
size: 'dir',
1614
date,
1715
owner: 0,
1816
mode: 33_204,
1917
};
2018

21-
module.exports.readifyRaw = {
19+
export const readifyRaw = {
2220
name: 'readify.js',
2321
size: 1629,
2422
date,
2523
owner: 0,
2624
mode: 33_204,
2725
};
2826

29-
module.exports.libRaw = {
27+
export const libRaw = {
3028
name: 'lib',
3129
size: 'dir',
3230
date: 0,

test/fixture.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
'use strict';
2-
3-
module.exports.sortifyFile = {
1+
export const sortifyFile = {
42
name: 'sortify.js',
53
size: '3.46kb',
64
date: '12.01.2017',
75
owner: 0,
86
mode: 'rw- rw- r--',
97
};
108

11-
module.exports.testDir = {
9+
export const testDir = {
1210
name: 'test',
1311
size: 'dir',
1412
date: '12.01.2017',
1513
owner: 0,
1614
mode: 'rw- rw- r--',
1715
};
1816

19-
module.exports.readifyFile = {
17+
export const readifyFile = {
2018
name: 'readify.js',
2119
size: '1.59kb',
2220
date: '12.01.2017',
2321
owner: 0,
2422
mode: 'rw- rw- r--',
2523
};
2624

27-
module.exports.libDir = {
25+
export const libDir = {
2826
name: 'lib',
2927
size: 'dir',
3028
date: '',

test/formatify.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
'use strict';
2-
3-
const {tryCatch} = require('try-catch');
4-
5-
const {test} = require('supertape');
6-
const formatify = require('..');
7-
8-
const {
1+
import {tryCatch} from 'try-catch';
2+
import {test} from 'supertape';
3+
import formatify from '../lib/formatify.js';
4+
import {
95
testDir,
106
libDir,
117
readifyFile,
128
sortifyFile,
13-
} = require('./fixture');
14-
15-
const {
9+
} from './fixture.js';
10+
import {
1611
testRaw,
1712
libRaw,
1813
readifyRaw,
1914
sortifyRaw,
20-
} = require('./fixture-raw');
15+
} from './fixture-raw.js';
2116

2217
test('formatify: arguments: exception when no files', (t) => {
2318
const [error] = tryCatch(formatify);

0 commit comments

Comments
 (0)