Last active
March 30, 2017 16:32
-
-
Save wardbell/d3d572c89eeff01fa7c151f18ec4f5b4 to your computer and use it in GitHub Desktop.
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
// Npm install Angular libraries into application root folder (APP_ROOT_PATH), | |
// either release or current build packages | |
// Examples: | |
// gulp install-example-angular --build // use current build packages | |
// gulp install-example-angular --build=2.0.0-b43f954 // use tagged packages | |
// gulp install-example-angular // restore release packages | |
// | |
// Find the tags here: https://github.com/angular/core-builds/releases | |
// | |
// Originally from https://github.com/angular/angular.io/blob/v2/gulpfile.js#L490 | |
gulp.task('install-example-angular', installExampleAngular); | |
function installExampleAngular() { | |
var APP_ROOT_PATH = '/'; | |
var sources; | |
var template; | |
var libs = [ | |
'core', 'common', 'compiler', 'compiler-cli', | |
'platform-browser', 'platform-browser-dynamic', | |
'forms', 'http', 'router', 'upgrade']; | |
var build = argv.build; | |
if (build) { | |
if (typeof build === 'string') { | |
build = (build[0]==='#' ? '' : '#') + build; | |
} else { | |
build = ''; | |
} | |
} else{ | |
build = 'npm'; | |
} | |
// Like: "angular/core-builds" or "@angular/core" | |
sources = libs.map( lib => { | |
return build === 'npm' | |
? `@angular/${lib}` | |
: `git+https://github.com/angular/${lib}-builds${build}`; | |
}); | |
if (argv.build) { sources.push('@angular/tsc-wrapped');} // tsc-wrapped needed for builds | |
console.log(`Installing Angular packages from ${build === 'npm' ? 'NPM' : 'BUILD ' + build}`); | |
var spawnInfo = spawnExt('rm', ['-rf', 'node_modules/@angular'], { cwd: APP_ROOT_PATH}); | |
return spawnInfo.promise | |
.then(() => { | |
spawnInfo = spawnExt('npm', ['install', ...sources], {cwd: APP_ROOT_PATH}); | |
return spawnInfo.promise | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a gulp (mostly node) script to replace the current contents of your apps
node_modules
with the current build, a tagged build, or the release build of Angular packages.It does NOT swap other packages that may be relevant such as zones or RxJS