MCPcopy
hub / github.com/formatjs/formatjs / main

Function main

tools/check_package_json.ts:70–104  ·  view source on GitHub ↗
(args: Args)

Source from the content-addressed store, hash-verified

68}
69
70function main(args: Args): void {
71 if (!args.pkg) {
72 console.error(
73 'Usage: check_package_json --pkg <package.json> --bundle <path>...'
74 )
75 process.exit(1)
76 }
77 const bundles = Array.isArray(args.bundle)
78 ? args.bundle
79 : args.bundle
80 ? [args.bundle]
81 : []
82 if (bundles.length === 0) {
83 console.error('FAIL: at least one --bundle must be provided')
84 process.exit(1)
85 }
86
87 const pkg = JSON.parse(readFileSync(args.pkg, 'utf8'))
88 const declared = new Set<string>([
89 ...Object.keys(pkg.dependencies ?? {}),
90 ...Object.keys(pkg.peerDependencies ?? {}),
91 ])
92
93 const errors: string[] = []
94 for (const bundle of bundles) {
95 checkBundle(bundle, declared, errors)
96 }
97
98 if (errors.length > 0) {
99 for (const err of errors) console.error(`FAIL: ${err}`)
100 process.exit(1)
101 }
102
103 console.log('PASS: all bundle imports are declared in package.json')
104}
105
106if (import.meta.filename === process.argv[1]) {
107 main(minimist<Args>(process.argv.slice(2)))

Callers 1

Calls 4

checkBundleFunction · 0.85
errorMethod · 0.80
parseMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected