1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Automatically run npm install when running npm start (#35283)

Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>
This commit is contained in:
Peter Bengtsson
2023-03-07 13:38:07 -05:00
committed by GitHub
parent 222be16582
commit e77b7bf06e
4 changed files with 38 additions and 0 deletions

31
script/cmp-files.js Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env node
// [start-readme]
//
// Given N files. Exit 0 if they all exist and are identical in content.
//
// [end-readme]
import fs from 'fs'
import { program } from 'commander'
program.description('Compare N files').arguments('[files...]', '').parse(process.argv)
main(program.args)
function main(files) {
if (files.length < 2) throw new Error('Must be at least 2 files')
try {
const contents = files.map((file) => fs.readFileSync(file, 'utf-8'))
if (new Set(contents).size > 1) {
process.exit(1)
}
} catch (error) {
if (error.code === 'ENOENT') {
process.exit(1)
} else {
throw error
}
}
}