-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
42 lines (38 loc) · 979 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict'
const { suite, test, before } = require('mocha')
const pkg = require('../package.json')
const fixtures = require('fs-test-fixtures')
const createPackage = require('..')
const fromEntries = require('object.fromentries')
const barePrompt = {
promptor: () => async (prompts) => {
// Set defaults from prompts
const out = await Promise.all(prompts.map(async (p) => {
if (!p.when) {
return []
}
let ret = typeof p.default === 'function' ? p.default({}) : p.default
if (ret && typeof ret.then === 'function') {
ret = await ret
}
return [p.name, ret]
}))
return fromEntries(out)
}
}
suite(pkg.name, () => {
let fix
before(() => {
fix = fixtures()
})
test('scaffolds a package', async function () {
await fix.setup()
await createPackage({
cwd: fix.TMP,
push: false,
silent: true,
githubRepo: '__tmp',
author: 'Unit test'
}, barePrompt)
})
})