-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.ts
55 lines (45 loc) · 1.29 KB
/
build.ts
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
43
44
45
46
47
48
49
50
51
52
53
54
55
import {
banner,
exec,
find,
hookAfter,
log,
mkdtemp,
plugjs,
resolve,
rmrf,
tasks,
} from '@plugjs/build'
import '@plugjs/tsd'
const localBuild = plugjs({
...tasks({
exportsGlob: '((index|dts-generator).*)|(extra/**.*)',
extraLint: [ [ '**/*.test-d.ts', { directory: 'test-d' } ] ],
}),
/** Run `tsd` */
async tsd(): Promise<void> {
await this.transpile()
banner('Testing type definitions')
await find('**/*.test-d.ts', { directory: 'test-d' }).tsd()
},
/** Text compilation of *dependant* packages */
async test_dependants(): Promise<void> {
await this.transpile()
banner('Testing transpilation of dependant packages')
const tmpdir = mkdtemp()
try {
// copy files to the temporary directory
await find('**/*', { directory: 'test/sources' })
.copy(tmpdir)
// instell ourselves as a module in the temporary directory
await exec('npm', 'install', '--no-save', '--prefix', tmpdir, resolve('.'))
// run tsc to make sure that all types are exported correctly
await find('**/*.ts', { directory: tmpdir }).tsc()
log('Sources compiled successfully')
} finally {
await rmrf(tmpdir)
}
},
})
hookAfter(localBuild, 'test', [ 'tsd', 'test_dependants' ])
export default localBuild