Skip to content

Commit

Permalink
Merge pull request #602 from desktop/rm-rf-rimraf
Browse files Browse the repository at this point in the history
Remove rimraf dependency in favor of Node native rm
  • Loading branch information
niik authored Nov 26, 2024
2 parents 48bc3ad + 1a28fb4 commit 9979d25
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 314 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "./build/lib/index.js",
"typings": "./build/lib/index.d.ts",
"scripts": {
"clean": "rimraf build",
"clean": "node script/clean.js",
"build": "yarn clean && tsc -p ./tsconfig.json && tsc -p ./examples/tsconfig.json",
"prepack": "yarn build && yarn test",
"postpublish": "git push --follow-tags",
Expand Down Expand Up @@ -36,11 +36,9 @@
"devDependencies": {
"@types/node": "20",
"@types/progress": "^2.0.1",
"@types/rimraf": "2.0.2",
"@types/temp": "^0.9.4",
"node-test-github-reporter": "^1.2.0",
"prettier": "^3.3.1",
"rimraf": "^5.0.7",
"temp": "^0.9.4",
"tsx": "^4.10.5",
"typescript": "^5.4.5"
Expand Down
6 changes: 6 additions & 0 deletions script/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { rm } = require('fs/promises')
const { join } = require('path')

rm(join(__dirname, '..', 'build'), { recursive: true, force: true }).catch(
console.error
)
54 changes: 17 additions & 37 deletions script/test.mjs
Original file line number Diff line number Diff line change
@@ -1,43 +1,23 @@
import { spawn } from 'child_process'
import { glob } from 'glob'
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
import { join } from 'path'
import { readdir } from 'fs/promises'

if (process.argv.some(arg => ['-h', '--help'].includes(arg))) {
console.log(`Usage: ${process.argv0} [kind]`)
console.log(
' kind: The kind of tests to run (e.g. "fast", "slow", "external", "all")'
)
process.exit(0)
function reporter(r) {
return ['--test-reporter', r, '--test-reporter-destination', 'stdout']
}

;(async function (kind) {
const wildcard = kind && kind !== 'all' ? `${kind}/**` : '**'
const files = await glob(`test/${wildcard}/*-test.ts`)
const reporterDestinationArgs = ['--test-reporter-destination', 'stdout']
const specTestReporterArgs = [
'--test-reporter',
'spec',
...reporterDestinationArgs,
]
const files = await readdir('test', { recursive: true }).then(x =>
x.filter(f => f.endsWith('-test.ts')).map(f => join('test', f))
)

const testReporterArgs = process.env.GITHUB_ACTIONS
? [
'--test-reporter',
'node-test-github-reporter',
...reporterDestinationArgs,
...specTestReporterArgs,
]
: specTestReporterArgs
process.env.LOCAL_GIT_DIRECTORY = 'git'

spawn('node', ['--import', 'tsx', ...testReporterArgs, '--test', ...files], {
stdio: 'inherit',
env: {
...process.env,
LOCAL_GIT_DIRECTORY: resolve(
dirname(fileURLToPath(import.meta.url)),
'../git/'
),
},
}).on('exit', process.exit)
})(process.argv[2])
const args = [
...['--import', 'tsx'],
'--test',
...reporter('spec'),
...(process.env.GITHUB_ACTIONS ? reporter('node-test-github-reporter') : []),
...files,
]

spawn('node', args, { stdio: 'inherit' }).on('exit', process.exit)
Loading

0 comments on commit 9979d25

Please sign in to comment.