Skip to content

Commit 8bd5461

Browse files
committed
feat(git): support packages in a subdirectory
1 parent dfccb4f commit 8bd5461

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/git.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const npm = require('./util/npm.js')
1616
const _resolvedFromRepo = Symbol('_resolvedFromRepo')
1717
const _resolvedFromHosted = Symbol('_resolvedFromHosted')
1818
const _resolvedFromClone = Symbol('_resolvedFromClone')
19+
const _subdirFromClone = Symbol('_subdirFromClone')
1920
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
2021
const _addGitSha = Symbol('_addGitSha')
2122
const _clone = Symbol('_clone')
@@ -138,6 +139,10 @@ class GitFetcher extends Fetcher {
138139
return this[_clone](dir => this.resolved)
139140
}
140141

142+
[_subdirFromClone] (handler) {
143+
return this[_clone](dir => handler(`${dir}${this.spec.gitSubdir || ''}`))
144+
}
145+
141146
[_prepareDir] (dir) {
142147
return readPackageJson(dir + '/package.json').then(mani => {
143148
// no need if we aren't going to do any preparation.
@@ -168,7 +173,7 @@ class GitFetcher extends Fetcher {
168173
stream.from = this.from
169174

170175
// check it out and then shell out to the DirFetcher tarball packer
171-
this[_clone](dir => this[_prepareDir](dir)
176+
this[_subdirFromClone](dir => this[_prepareDir](dir)
172177
.then(() => new Promise((res, rej) => {
173178
const df = new DirFetcher(`file:${dir}`, {
174179
...this.opts,
@@ -256,7 +261,7 @@ class GitFetcher extends Fetcher {
256261

257262
return this.spec.hosted && this.resolved
258263
? FileFetcher.prototype.manifest.apply(this)
259-
: this[_clone](dir =>
264+
: this[_subdirFromClone](dir =>
260265
readPackageJson(dir + '/package.json')
261266
.then(mani => this.package = {
262267
...mani,

0 commit comments

Comments
 (0)