Skip to content

Commit 2497a8c

Browse files
committed
Add gulp pack
1 parent 1e283ad commit 2497a8c

File tree

12 files changed

+111
-8
lines changed

12 files changed

+111
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ core
1010
.nyc_output
1111
coverage
1212
dist
13+
build

.nycrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"include": ["dist", "{index,register}.js"],
2+
"include": ["build"],
33
"all": true,
44
"reporter": ["lcov", "text"]
55
}

gulp/tasks/build.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ const { getWatchTask } = require('../utils')
66
const { BUILD_SRC, BUILD_DIST } = require('../files')
77
const gulpExeca = require('../exec')
88

9+
const { pack } = require('./pack')
10+
911
const babel = () =>
1012
gulpExeca(
1113
`babel ${BUILD_SRC} --out-dir ${BUILD_DIST} --copy-files --delete-dir-on-start --source-maps --no-comments --minified --retain-lines`,
1214
)
1315

14-
const build = series(babel)
16+
const build = series(babel, pack)
1517

1618
// eslint-disable-next-line fp/no-mutation
1719
build.description = 'Build source files'

gulp/tasks/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ module.exports = {
66
...require('./check'),
77
...require('./unit'),
88
...require('./build'),
9+
...require('./pack'),
910
...require('./emit'),
1011
}

gulp/tasks/pack.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict'
2+
3+
const { rename, unlink } = require('fs')
4+
const { promisify } = require('util')
5+
6+
const { extract } = require('tar')
7+
const rimraf = require('rimraf')
8+
9+
const { name, version } = require('../../package')
10+
const gulpExeca = require('../exec')
11+
12+
const pack = async function() {
13+
// Create tarball
14+
await gulpExeca('npm pack', { stdout: 'ignore' })
15+
16+
// Unzip tarball
17+
const file = `${name}-${version}.tgz`
18+
await extract({ file })
19+
20+
// Remove previous directory and temporary files
21+
await Promise.all([promisify(unlink)(file), promisify(rimraf)('build')])
22+
23+
// Rename directory
24+
await promisify(rename)('package', 'build')
25+
}
26+
27+
// eslint-disable-next-line fp/no-mutation
28+
pack.description = 'Run npm pack to create a build directory'
29+
30+
module.exports = {
31+
pack,
32+
}

package-lock.json

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@
9191
"plugin-error": "^1.0.1",
9292
"prettier": "^1.15.2",
9393
"release-it": "^8.0.1",
94+
"rimraf": "^2.6.2",
9495
"sinon": "^7.1.1",
9596
"source-map-support": "^0.5.9",
96-
"strip-ansi": "^5.0.0"
97+
"strip-ansi": "^5.0.0",
98+
"tar": "^4.4.8"
9799
},
98100
"engines": {
99101
"node": ">=11.2.0"

test/exit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const lolex = require('lolex')
88

99
const {
1010
constants: { EXIT_TIMEOUT, EXIT_STATUS },
11-
} = require('../dist')
11+
} = require('../build')
1212

1313
const { repeatEvents, startLogging } = require('./helpers')
1414

test/helpers/emit/fire.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { argv } = require('process')
44

5-
const { init } = require('../../..')
5+
const { init } = require('../../../build')
66

77
const { ALL_EVENTS } = require('./main')
88

test/helpers/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const sinon = require('sinon')
44

5-
const { init } = require('../..')
5+
const { init } = require('../../build')
66

77
// Call `logProcessErrors()` then return spied objects and `stopLogging()`
88
const startLoggingNoOpts = function() {

0 commit comments

Comments
 (0)