Skip to content

Commit

Permalink
test: eslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Nov 30, 2024
1 parent 116f310 commit a0cd3c3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module.exports = {
extends: require.resolve('@ostai/eslint-config'),
rules: {
'prefer-object-spread': OFF,
'import/no-unresolved': OFF
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

[![Build Status](https://github.com/kaelzhang/shell-safe-rm/actions/workflows/nodejs.yml/badge.svg)](https://github.com/kaelzhang/shell-safe-rm/actions/workflows/nodejs.yml)

[Safe-rm][safe-rm], a much safer replacement of [`rm`][rm] with **ALMOST FULL** features of the origin [`rm`][rm] command.
[Safe-rm][safe-rm], a drop-in and much safer replacement of the unix [`rm`][rm] command with **ALMOST FULL** features of the original [`rm`][rm].

The project was initially developed for Mac OS X, and then tested on Linux.

Expand Down
17 changes: 6 additions & 11 deletions test/cases.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
const path = require('path')
const {v4: uuid} = require('uuid')
const delay = require('delay')
const log = require('util').debuglog('safe-rm')

const {
generateContextMethods,
assertEmptySuccess,
IS_MACOS
} = require('./helper')


module.exports = (
test,
des_prefix,
test_trash_dir = true,
test_trash_dir,
rm_command,
env = {}
) => {

// Setup before each test
test.beforeEach(generateContextMethods(rm_command, env))

Expand All @@ -43,7 +40,8 @@ module.exports = (

t.is(files.length, 1, 'should be one in the trash')
t.is(
path.basename(files[0]), path.basename(filepath),
path.basename(files[0]),
path.basename(filepath),
'file name should match'
)
})
Expand Down Expand Up @@ -95,7 +93,6 @@ module.exports = (
return
}


const files = (await lsFileInTrash(full_name))
.sort((a, b) => a.length - b.length)

Expand All @@ -120,6 +117,7 @@ module.exports = (
t.true(files.every(f => f.endsWith(ext)), 'should have the same ext')

t.is(fb1, filename)
t.is(fbs1[0], filename)
t.is(fbs2[0], filename)
t.is(fbs3[0], filename)

Expand All @@ -136,7 +134,7 @@ module.exports = (
for (const file of files) {
const match = file.match(re)
const n = match[2]
? parseInt(match[2])
? parseInt(match[2], 10)
: 0

const f = file.slice(0, match.index)
Expand Down Expand Up @@ -184,10 +182,7 @@ module.exports = (
test(`${des_prefix}: #22 exit code with -f option`, async t => {
const {
source_path,
createFile,
runRm,
pathExists,
lsFileInTrash
runRm
} = t.context

const filepath = path.join(source_path, uuid())
Expand Down
7 changes: 3 additions & 4 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ const generateContextMethods = (
}
}


async function lsFileInMacTrash (filepath) {
const {trash_path} = t.context

Expand Down Expand Up @@ -161,9 +160,9 @@ const generateContextMethods = (
}

const assertEmptySuccess = (t, result, a = '', b = '', c = '') => {
t.is(result.code, 0, 'exit code should be 0' + a)
t.is(result.stdout, '', 'stdout should be empty' + b)
t.is(result.stderr, '', 'stderr should be empty' + c)
t.is(result.code, 0, `exit code should be 0${a}`)
t.is(result.stdout, '', `stdout should be empty${b}`)
t.is(result.stderr, '', `stderr should be empty${c}`)
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion test/safe-rm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ const test = require('ava')

const factory = require('./cases')

factory(test, 'safe-rm')
factory(test, 'safe-rm', true)

0 comments on commit a0cd3c3

Please sign in to comment.