Skip to content

Commit affeb7e

Browse files
committed
feature: readify: migrate to ESM
1 parent e7ae40e commit affeb7e

8 files changed

Lines changed: 30 additions & 51 deletions

File tree

File renamed without changes.

.travis.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

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/readdir.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
'use strict';
1+
import {join, extname} from 'node:path';
2+
import {readdir as _readdir} from 'node:fs/promises';
3+
import currify from 'currify';
4+
import {tryToCatch} from 'try-to-catch';
5+
import _superstat from 'superstat';
26

3-
const {join, extname} = require('node:path');
4-
const {readdir: _readdir} = require('node:fs/promises');
5-
const currify = require('currify');
6-
const {tryToCatch} = require('try-to-catch');
7-
const _superstat = require('superstat');
87
const noop = () => {};
98
const {assign} = Object;
109

@@ -17,11 +16,12 @@ const stat = currify(async (superstat, dir, name) => {
1716
});
1817
});
1918

20-
module.exports.readdir = async (dir, overrides = {}) => {
19+
export const readdir = async (dir, overrides = {}) => {
2120
const {
2221
readdir = _readdir,
2322
superstat = _superstat,
2423
} = overrides;
24+
2525
const names = await readdir(dir);
2626

2727
const statsPromises = names.map(stat(superstat, dir));

lib/readify.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
'use strict';
1+
import format from 'format-io';
2+
import currify from 'currify';
3+
import {tryToCatch} from 'try-to-catch';
4+
import sortify from '@cloudcmd/sortify';
5+
import {formatify} from '@cloudcmd/formatify';
6+
import _nicki from 'nicki';
7+
import {readdir as _readdir} from './readdir.js';
28

3-
const format = require('format-io');
4-
5-
const currify = require('currify');
6-
const {tryToCatch} = require('try-to-catch');
7-
8-
const sortify = require('@cloudcmd/sortify');
9-
const {formatify} = require('@cloudcmd/formatify');
10-
11-
const _nicki = require('nicki');
12-
const {readdir: _readdir} = require('./readdir');
139
const isUndefined = (a) => typeof a === 'undefined';
1410

1511
const replaceProperty = currify(_replaceProperty);
1612
const ifRaw = currify(_ifRaw);
1713
const isString = (a) => typeof a === 'string';
1814

19-
module.exports.readify = async (path, options = {}) => {
15+
export const readify = async (path, options = {}) => {
2016
const {
2117
type,
2218
order,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "readify",
33
"version": "10.0.1",
4-
"type": "commonjs",
4+
"type": "module",
55
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
66
"description": "Read directory content with file attributes: size, date, owner, mode",
77
"homepage": "http://github.com/coderaiser/readify",

test/readdir.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
'use strict';
2-
3-
const {test, stub} = require('supertape');
4-
5-
const {tryToCatch} = require('try-to-catch');
6-
const {readdir: _readdir} = require('../lib/readdir');
1+
import {test, stub} from 'supertape';
2+
import {tryToCatch} from 'try-to-catch';
3+
import {readdir as _readdir} from '../lib/readdir.js';
74

85
const noop = () => {};
96

test/readify.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
'use strict';
1+
import process from 'node:process';
2+
import {fileURLToPath} from 'node:url';
3+
import {dirname} from 'node:path';
4+
import {test, stub} from 'supertape';
5+
import {tryToCatch} from 'try-to-catch';
6+
import shortdate from 'shortdate';
7+
import {readify} from '../lib/readify.js';
28

3-
const process = require('node:process');
4-
const {test, stub} = require('supertape');
5-
6-
const {tryToCatch} = require('try-to-catch');
7-
const shortdate = require('shortdate');
8-
9-
const {readify} = require('..');
9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = dirname(__filename);
1011

1112
test('readify: path: wrong', async (t) => {
1213
const [error] = await tryToCatch(readify, '/wrong/path');

0 commit comments

Comments
 (0)