-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(allow-multiple-targets): Allow multiple target packages
Allow multiple target packages to install into. * Change the `installLocal` function to accept an object hash. * Change the command line utility to work more like `npm install`. Only installing into current directory
- Loading branch information
Showing
9 changed files
with
140 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/usr/bin/env node | ||
process.title = 'install-local'; | ||
require('../src/cli'); | ||
require('../src/cli').cli(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
import { installLocal } from './index'; | ||
|
||
const args = process.argv | ||
.filter((_, i) => i > 1); | ||
export function cli(argv: string[]) { | ||
|
||
if (args.length < 2) { | ||
console.log(); | ||
console.log('Install packages locally without changing the package.json'); | ||
console.log(); | ||
console.log('Usage: install-local <from> <to> [<to>, ...]'); | ||
console.log('Installs package in <from> directory in package of <to> directories.'); | ||
process.exit(1); | ||
const args = argv | ||
.filter((_, i) => i > 1); | ||
|
||
if (args.length < 1) { | ||
console.log(); | ||
console.log('Install packages locally without changing the package.json'); | ||
console.log(); | ||
console.log('Usage: install-local <folder>[, <folder>, ...]'); | ||
console.log(''); | ||
console.log('Installs a package from the filesystem into the current directory without touching the package.json.'); | ||
console.log(''); | ||
console.log('Examples: '); | ||
console.log(' install-local ..'); | ||
console.log(' install the package located in the parent folder into the current directory.'); | ||
console.log(' install-local ../sibling ../sibling2'); | ||
console.log(' install the packages in 2 sibling directories into the current directory.'); | ||
console.log(' install-local'); | ||
console.log(' Print this help.'); | ||
process.exit(1); | ||
} else { | ||
installLocal({ '.': args }).catch(err => { | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
} | ||
} | ||
installLocal(args[0], ...args.slice(1)).catch(err => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { expect } from 'chai'; | ||
import * as path from 'path'; | ||
import { mapToPackagesBySource } from '../../src/index'; | ||
|
||
describe('mapToPackagesBySource', () => { | ||
|
||
it('should map { "../..": "..", "__dirname": ".."} to one and the same', () => { | ||
const input = { | ||
[__dirname + '/./']: ['..'], | ||
[__dirname]: ['..'] | ||
}; | ||
const result = mapToPackagesBySource(input); | ||
expect(result).to.deep.eq({ [path.resolve('..')]: [path.resolve(__dirname)] }); | ||
}); | ||
|
||
it('should map { ".": ["./stryker", "./stryker-api"], "../sibling": ["./stryker", "./stryker-api"] } to 2 records', () => { | ||
const input = { | ||
'.': ['./stryker', './stryker-api'], | ||
'../sibling': ['./stryker', './stryker-api'] | ||
}; | ||
const result = mapToPackagesBySource(input); | ||
expect(result).to.deep.eq({ | ||
[path.resolve('./stryker')]: [path.resolve('.'), path.resolve('../sibling')], | ||
[path.resolve('./stryker-api')]: [path.resolve('.'), path.resolve('../sibling')] | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters