-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove rimraf dependency in favor of Node native rm #602
Merged
+24
−314
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b977a61
Remove rimraf dependency in favor of Node native rm
niik 4b7b0e9
Replace glob with recursive readdir
niik a0f4339
All tests are pretty fast nowadays, let's skip this complication
niik 0a12822
Praise top level await!
niik 019f99d
:art: cleanup
niik d38c206
We already require this script to be run from the root
niik 97099dc
Whoops
niik 1a28fb4
The minification continues
niik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So turns out I was depending on a sub-dependency of rimraf here so when I removed it
glob
disappeared as well but that lead to a nice cleanup in this script as well, utilizing the recursive option of readdirThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup indeed 🥹