-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
16 lines (15 loc) · 807 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const { writeFileSync, readFileSync, existsSync, lstatSync } = require('fs')
const { execSync } = require('child_process')
const { resolve, join } = require('path')
module.exports = path => {
if (!(path && typeof path === 'string' && path.length > 0 && existsSync(path) && lstatSync(path).isDirectory())) throw new Error('Please enter a valid path')
const pathh = resolve(path)
const pkgpath = join(pathh, 'package.json')
const pkg = JSON.parse(readFileSync(pkgpath))
pkg.scripts.test = 'standard && node test.js | tap-spec'
writeFileSync(join(pathh, 'test.js'), "const tap = require('tap') \nconst pcj = require('./App')")
writeFileSync(join(pathh, 'package.json'), JSON.stringify(pkg, null, 2))
return execSync('npm i standard tap tap-spec --save-dev', {
cwd: pathh
}).toString()
}