Skip to content

Commit bab148e

Browse files
authored
Adding support for shama#72 single file download
1 parent 09bd26e commit bab148e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/pkg.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function NapaPkg (url, name, opts) {
3131
: path.resolve(this.cwd, opts['cache-path']),
3232
this.url
3333
)
34+
this.strictDecompress = !!opts.strictDecompress
3435
this._napaResolvedKey = '_napaResolved'
3536
this.saveToPkgJson = opts.save
3637

@@ -109,7 +110,12 @@ NapaPkg.prototype.install = function (done) {
109110
self._mock(['download', self.url, self.installTo])
110111
} else {
111112
self.log.info('download', '%s into %s', self.url, self.name)
112-
download(self.url, self.installTo, { extract: true, strip: 1 })
113+
var extractOptions = { extract: true, strip: 1 }
114+
if (self.strictDecompress) {
115+
// decompress module options
116+
extractOptions = /(\.zip$)|(\.tar$)|(\.tar\.(gz|bz2?|xz)$)/.test(self.url) ? extractOptions : {}
117+
}
118+
download(self.url, self.installTo, extractOptions)
113119
.then(function () { cb() }, cb)
114120
}
115121
}

0 commit comments

Comments
 (0)