UNPKG

1.03 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3const fs = require('fs')
4const path = require('path')
5
6const checks = []
7function check(name, callback) {
8 checks.push([checks.length + 1, name, callback])
9}
10
11function run() {
12 process.stdout.write(`1..${checks.length}\n`)
13 checks.forEach(([count, name, callback]) => {
14 Promise.resolve()
15 .then(callback)
16 .then(() => {
17 process.stdout.write(`ok ${count} - ${name}\n`)
18 })
19 .catch(error => {
20 process.stdout.write(`not ok ${count} - ${name}\n ${error}\n`)
21 })
22 })
23}
24
25const packageRoot = process.argv[2]
26
27check('package.json exists', () => {
28 const packageJsonPath = path.join(packageRoot, 'package.json')
29
30 if (!fs.existsSync(packageJsonPath)) {
31 throw new Error('package.json does not exist')
32 }
33})
34
35check('package.json license is set', () => {
36 const packageJsonPath = path.join(packageRoot, 'package.json')
37 const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
38
39 if (!pkg.license) {
40 throw new Error('license not set')
41 }
42})
43
44run()