Skip to content

Commit 3dc3d31

Browse files
committed
enable github installs
1 parent 5c1a2ee commit 3dc3d31

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

‎README.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ Create a JSON spec of packages to be installed, e.g. at `test/multidep.json`:
3333

3434
Do not use fuzzy versions (`"^0.16.0"`) - this will cause problems.
3535

36+
#### Installing the packages from GitHub
37+
38+
To specify a package from GitHub, specify an array where the first value points
39+
to a GitHub repository (optionally with branch or tag), and the second value
40+
will be suffixed to the install path. This will install the `somebranch` branch
41+
of the `username/brocolli` repository to `test/multidep_modules/brocolli-thatbranch`:
42+
43+
```json
44+
{
45+
"path": "test/multidep_modules",
46+
"versions": {
47+
"broccoli": [["username/brocolli#somebranch", "thatbranch"]]
48+
}
49+
}
50+
```
51+
52+
This is currently only for installing, does not work with requiring.
53+
3654
### Installing the packages from npm
3755

3856
Next, run

‎index.js‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,29 @@ module.exports.install = function(specPath) {
7272
Object.keys(spec.versions).sort().forEach(function(packageName) {
7373
spec.versions[packageName].forEach(function(version) {
7474
promise = promise.then(function() {
75-
var packagePath = path.join(spec.path, packageName + '-' + version)
75+
var packagePath
76+
// If version is an array, first arg is NPM path and second is alias.
77+
if (version.constructor === Array) {
78+
packagePath = path.join(spec.path, packageName + '-' + version[1])
79+
} else {
80+
packagePath = path.join(spec.path, packageName + '-' + version)
81+
}
7682
return RSVP.resolve()
7783
.then(function() {
7884
if (!fs.existsSync(packagePath)) {
7985
console.log(packageName + ' ' + version + ': Installing')
8086
fs.mkdirSync(packagePath)
8187
fs.mkdirSync(path.join(packagePath, 'node_modules'))
82-
var cp = spawn('npm', ['install', packageName + '@' + version], {
88+
89+
var installName;
90+
// If version is an array, first arg is NPM path and second is alias.
91+
if (version.constructor === Array) {
92+
installName = version[0]
93+
} else {
94+
installName = packageName + '@' + version
95+
}
96+
97+
var cp = spawn('npm', ['install', installName], {
8398
cwd: packagePath,
8499
stdio: 'inherit',
85100
timeout: 300

0 commit comments

Comments
 (0)