Skip to content

Commit 050a3fc

Browse files
committed
fix: postinstall script not working properly - fixes #220
1 parent 357f01d commit 050a3fc

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
### Breaking Change
99
### Fixed
1010
- Fix `curly.post` and `curly.head` using wrong libcurl options to set the HTTP Method.
11+
- Fix `postinstall` script not working properly.
1112
### Added
1213
### Changed
1314

scripts/postinstall.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ function printStandardLibError() {
4343
log.error('$ sudo apt-get install libstdc++-4.9-dev')
4444
}
4545

46+
function cleanup() {
47+
// If we're using node-libcurl from a package manager then let's clean up after
48+
// ourselves when we install successfully - unless specified not to.
49+
if (!buildFlags.mustBuild) {
50+
rimraf.sync(path.join(rootPath, 'build'))
51+
if (fs.existsSync(path.join(rootPath, 'curl-for-windows'))) {
52+
rimraf.sync(path.join(rootPath, 'curl-for-windows'))
53+
}
54+
}
55+
}
56+
4657
module.exports = function install() {
4758
if (buildFlags.isGitRepo) {
4859
// If we're building NodeGit from a git repo we aren't going to do any
@@ -53,6 +64,7 @@ module.exports = function install() {
5364
if (buildFlags.isElectron || buildFlags.isNWjs) {
5465
// If we're building for electron or NWjs, we're unable to require the
5566
// built library so we have to just assume success, unfortunately.
67+
cleanup()
5668
return Promise.resolve()
5769
}
5870

@@ -74,21 +86,7 @@ module.exports = function install() {
7486
throw e
7587
}
7688
})
77-
.then(function () {
78-
// If we're using node-libcurl from a package manager then let's clean up after
79-
// ourselves when we install successfully.
80-
if (!buildFlags.mustBuild) {
81-
// We can't remove the source files yet because apparently the
82-
// "standard workflow" for native node modules in Electron/nwjs is to
83-
// build them for node and then nah eff that noise let's rebuild them
84-
// again for the actual platform! Hurray!!! When that madness is dead
85-
// we can clean up the source which is a serious amount of data.
86-
rimraf.sync(path.join(rootPath, 'build'))
87-
if (fs.existsSync(path.join(rootPath, 'curl-for-windows'))) {
88-
rimraf.sync(path.join(rootPath, 'curl-for-windows'))
89-
}
90-
}
91-
})
89+
.then(cleanup)
9290
}
9391

9492
// Called on the command line

0 commit comments

Comments
 (0)