Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Mar 29, 2024
1 parent 300ac78 commit 41e5281
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 94 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"node/no-unsupported-features/node-builtins": "off"
},
"extends": [
"plugin:node/recommended",
"plugin:n/recommended",
"plugin:putout/recommended"
],
"plugins": [
"putout",
"node"
"n"
]
}
68 changes: 30 additions & 38 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,37 @@
name: Node CI

on: [push, pull_request]

on:
- push
- pull_request
jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 15.x]

node-version:
- 18.x
- 20.x
- 21.x
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install Redrun
run:
npm i redrun -g

- name: Install
run:
npm install

- name: Bootstrap
run:
redrun bootstrap

- name: Lint
run:
redrun lint

- name: Coverage
run:
redrun coverage report

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Redrun
run: bun i redrun -g --no-save
- name: Install
run: bun i --no-save
- name: Bootstrap
run: redrun bootstrap
- name: Lint
run: redrun lint
- name: Coverage
run: redrun coverage report
- name: Coveralls
uses: coverallsapp/github-action@v2
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ yarn-error.log
.nyc_output
*.swp

.idea
1 change: 0 additions & 1 deletion .madrun.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ export default {
'watch:test': () => run('watcher', 'npm test'),
'watcher': () => 'nodemon -w test -w lib --exec',
};

14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Readify [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
# Readify [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]

[NPMIMGURL]: https://img.shields.io/npm/v/readify.svg?style=flat
[BuildStatusURL]: https://github.com/coderaiser/readify/actions?query=workflow%3A%22Node+CI%22 "Build Status"
[BuildStatusIMGURL]: https://github.com/coderaiser/readify/workflows/Node%20CI/badge.svg
[DependencyStatusIMGURL]: https://img.shields.io/david/coderaiser/readify.svg?style=flat
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/readify "npm"
[DependencyStatusURL]: https://david-dm.org/coderaiser/readify "Dependency Status"
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
[CoverageURL]: https://coveralls.io/github/coderaiser/readify?branch=master
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/readify/badge.svg?branch=master&service=github
Expand Down Expand Up @@ -52,7 +50,9 @@ console.log(data);
}],
});

readify('/', {type: 'raw'}).then(console.log);
readify('/', {
type: 'raw',
}).then(console.log);
// output
({
path: '/',
Expand All @@ -66,7 +66,11 @@ readify('/', {type: 'raw'}).then(console.log);
}],
});

readify('/', {type: 'raw', sort: 'size', order: 'desc'}).then(console.log);
readify('/', {
type: 'raw',
sort: 'size',
order: 'desc',
}).then(console.log);
// output
({
path: '/',
Expand Down
1 change: 0 additions & 1 deletion lib/readdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,3 @@ function getType({name, isDir, isLink}) {

return `${type}${link}`;
}

13 changes: 6 additions & 7 deletions lib/readify.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const process = require('node:process');
const isUndefined = (a) => typeof a === 'undefined';
const format = require('format-io');
const currify = require('currify');
const tryToCatch = require('try-to-catch');
Expand All @@ -9,12 +11,10 @@ const formatify = require('@cloudcmd/formatify');

const WIN = process.platform === 'win32';

const ifRaw = currify(_ifRaw);
const replaceProperty = currify(_replaceProperty);

const nicki = !WIN && require('nicki');

const readdir = require('./readdir');
const nicki = !WIN && require('nicki');
const replaceProperty = currify(_replaceProperty);
const ifRaw = currify(_ifRaw);
const isString = (a) => typeof a === 'string';

module.exports = readify;
Expand Down Expand Up @@ -97,12 +97,11 @@ function _replaceProperty(obj, prop, item) {
const n = item[prop];
const data = obj[n];

if (typeof data === 'undefined')
if (isUndefined(data))
return item;

return {
...item,
[prop]: data,
};
}

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "readify",
"version": "9.0.0",
"type": "commonjs",
"author": "coderaiser <[email protected]> (https://github.com/coderaiser)",
"description": "Read directory content with file attributes: size, date, owner, mode",
"homepage": "http://github.com/coderaiser/readify",
Expand Down
13 changes: 5 additions & 8 deletions test/readdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

const fs = require('fs');

const stub = require('@cloudcmd/stub');
const test = require('supertape');
const {test, stub} = require('supertape');
const mockRequire = require('mock-require');
const {reRequire, stopAll} = mockRequire;
const tryToCatch = require('try-to-catch');

const tryToCatch = require('try-to-catch');
const {reRequire, stopAll} = mockRequire;
const noop = () => {};

test('readdir: empty dir', async (t) => {
const {readdir} = fs.promises;

fs.promises.readdir = async () => [];

const _readdir = reRequire('../lib/readdir');
Expand All @@ -31,9 +31,7 @@ test('readdir: empty stat', async (t) => {
throw Error('some');
});

fs.promises.readdir = async () => [
'hello',
];
fs.promises.readdir = async () => ['hello'];

const _readdir = reRequire('../lib/readdir');

Expand Down Expand Up @@ -245,4 +243,3 @@ test('readdir: result: directory link: no error', async (t) => {
t.notOk(e, e?.message || 'should not receive error');
t.end();
});

Loading

0 comments on commit 41e5281

Please sign in to comment.