-
Notifications
You must be signed in to change notification settings - Fork 198
Adds support for npm to polymer install.
#145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7454dca
Call `npm install` if the `--npm` flag is passed or set in the config…
bicknellr 3439242
Update descriptions.
bicknellr 059521b
Update old integration test that assumed `polymer install` didn't sup…
bicknellr b6b2354
Merge remote-tracking branch 'origin/master' into install-npm
bicknellr b8ba2c2
Remove `util.promisify` use (not available in Node.js 6).
bicknellr db10a0c
Merge remote-tracking branch 'origin/master' into install-npm
bicknellr 58b7467
Copy `--npm` description from cli to polyserve.
bicknellr 6d3357f
Merge remote-tracking branch 'origin/master' into install-npm
bicknellr 76b2aad
Move promisified `exec` to install command.
bicknellr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,14 +14,17 @@ | |
|
|
||
| import * as bower from 'bower'; | ||
| import {read as readBowerJson} from 'bower-json'; | ||
| import * as child_process from 'child_process'; | ||
| import * as path from 'path'; | ||
| import * as logging from 'plylog'; | ||
| import * as util from 'util'; | ||
|
|
||
| import defaultBowerConfig = require('bower/lib/config'); | ||
| import BowerLogger = require('bower-logger'); | ||
| import StandardRenderer = require('bower/lib/renderers/StandardRenderer'); | ||
| import BowerProject = require('bower/lib/core/Project'); | ||
|
|
||
| const exec = util.promisify(child_process.exec); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is sadly not available in node 6, we just aren't running node 6 integration tests currently (see #136) |
||
| const logger = logging.getLogger('cli.install'); | ||
|
|
||
| type JsonValue = string|number|boolean|null|JsonObject|JsonArray; | ||
|
|
@@ -35,25 +38,37 @@ interface JsonArray extends Array<JsonValue> {} | |
| export interface Options { | ||
| variants?: boolean; | ||
| offline?: boolean; | ||
| npm?: boolean; | ||
| } | ||
|
|
||
| export async function install(options?: Options): Promise<void> { | ||
| if (options && options.npm) { | ||
| await npmInstall(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Equivalent and simpler: |
||
| return; | ||
| } | ||
|
|
||
| // default to false | ||
| const offline = options == null ? false : options.offline === true; | ||
| // default to false | ||
| const variants = options == null ? false : options.variants === true; | ||
|
|
||
| await Promise.all([ | ||
| installDefault(offline), | ||
| variants ? installVariants(offline) : Promise.resolve(), | ||
| bowerInstallDefault(offline), | ||
| variants ? bowerInstallVariants(offline) : Promise.resolve(), | ||
| ]); | ||
| } | ||
|
|
||
| async function npmInstall() { | ||
| logger.info('Installing npm dependencies...'); | ||
| await exec('npm install', {cwd: process.cwd()}); | ||
| logger.info('Finished installing npm dependencies.'); | ||
| } | ||
|
|
||
| /** | ||
| * Performs a Bower install, optionally with a specific JSON configuration and | ||
| * output directory. | ||
| */ | ||
| async function _install( | ||
| async function _bowerInstall( | ||
| offline: boolean, | ||
| bowerJson?: JsonObject, | ||
| componentDirectory?: string, | ||
|
|
@@ -90,13 +105,13 @@ async function _install( | |
| await project.install([], {save: false, offline}, config); | ||
| } | ||
|
|
||
| async function installDefault(offline: boolean): Promise<void> { | ||
| async function bowerInstallDefault(offline: boolean): Promise<void> { | ||
| logger.info(`Installing default Bower components...`); | ||
| await _install(offline); | ||
| await _bowerInstall(offline); | ||
| logger.info(`Finished installing default Bower components`); | ||
| } | ||
|
|
||
| async function installVariants(offline: boolean): Promise<void> { | ||
| async function bowerInstallVariants(offline: boolean): Promise<void> { | ||
| const bowerJson = await new Promise<any>((resolve, reject) => { | ||
| const config = defaultBowerConfig({ | ||
| save: false, | ||
|
|
@@ -120,7 +135,7 @@ async function installVariants(offline: boolean): Promise<void> { | |
| const variantDirectory = `bower_components-${variantName}`; | ||
| logger.info( | ||
| `Installing variant ${variantName} to ${variantDirectory}...`); | ||
| await _install(offline, variantBowerJson, variantDirectory, variantName); | ||
| await _bowerInstall(offline, variantBowerJson, variantDirectory, variantName); | ||
| logger.info(`Finished installing variant ${variantName}`); | ||
| })); | ||
| } | ||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really do this in a unified place