chore(harp compile): Fix for issue with harp compile not being able to coexist with large node_modules

closes #670
+ added support for making harp compile errors visible when running check-deploy task.
This commit is contained in:
Jay Traband 2016-01-08 17:55:46 -08:00 committed by Ward Bell
parent 3460f35a9f
commit a53bfbc0c1
2 changed files with 51 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
node_modules
_temp
bower_components
jspm_packages
typings

View File

@ -30,7 +30,9 @@ var treeKill = require("tree-kill");
var TOOLS_PATH = './tools';
var ANGULAR_PROJECT_PATH = '../angular';
var PUBLIC_PATH = './public';
var TEMP_PATH = './_temp';
var DOCS_PATH = path.join(PUBLIC_PATH, 'docs');
var EXAMPLES_PATH = path.join(DOCS_PATH, '_examples');
var NOT_API_DOCS_GLOB = path.join(PUBLIC_PATH, './{docs/*/latest/!(api),!(docs)}/**/*');
var RESOURCES_PATH = path.join(PUBLIC_PATH, 'resources');
@ -344,8 +346,7 @@ gulp.task('git-changed-examples', ['_shred-devguide-examples'], function(){
});
gulp.task('check-deploy', ['build-docs'], function() {
gutil.log('running harp compile...');
return execPromise('npm run harp -- compile . ./www', {}).then(function() {
return harpCompile().then(function() {
gutil.log('compile ok - running live server ...');
execPromise('npm run live-server ./www');
return askDeploy();
@ -363,7 +364,6 @@ gulp.task('check-deploy', ['build-docs'], function() {
});
});
gulp.task('test-api-builder', function (cb) {
execCommands(['npm run test-api-builder'], {}, cb);
});
@ -371,7 +371,14 @@ gulp.task('test-api-builder', function (cb) {
// Internal tasks
// used to test just harpCompile without a build step
gulp.task('_harp-compile', function() {
return harpCompile().then(function() {
gutil.log('compile ok');
}).catch(function(e) {
gutil.log('compile failed');
});
});
gulp.task('_shred-devguide-examples', ['_shred-clean-devguide'], function() {
return docShredder.shred( _devguideShredOptions);
@ -400,6 +407,45 @@ gulp.task('_zip-examples', function() {
// Helper functions
function harpCompile() {
var deferred = Q.defer();
gutil.log('running harp compile...');
showHideExampleNodeModules('hide');
var spawnInfo = spawnExt('npm',['run','harp', '--', 'compile', '.', './www' ]);
spawnInfo.promise.then(function(x) {
showHideExampleNodeModules('show');
if (x !== 0) {
deferred.reject(x)
} else {
deferred.resolve(x);
}
}).catch(function(e) {
showHideExampleNodeModules('show');
deferred.reject(e);
});
return deferred.promise;
}
// harp has issues with node_modules under the public dir
// but we need them there for example testing and development
// this method allows the node modules folder under '_examples'
// to be temporarily moved out from under 'public' while harp
// compilation is occurring.
function showHideExampleNodeModules(showOrHide) {
var nmPath = path.join(EXAMPLES_PATH, "/node_modules");
var nmHiddenPath = path.join(TEMP_PATH, "/node_modules");
if (showOrHide == 'hide' && fs.existsSync(nmPath)) {
if (!fs.existsSync(TEMP_PATH)) {
fs.mkdirSync(TEMP_PATH);
}
fs.renameSync(nmPath, nmHiddenPath);
} else if (showOrHide == 'show' && fs.existsSync(nmHiddenPath)) {
fs.renameSync(nmHiddenPath, nmPath);
fs.rmdirSync(TEMP_PATH);
}
}
// returns a promise
function copyFiles(fileNames, destPaths) {
var copy = Q.denodeify(fsExtra.copy);