added browser-sync, modified shred-single-dir in doc-shredder to return a promise, updated readme.
This commit is contained in:
parent
ba7364ec9e
commit
9b61d586bf
|
@ -28,9 +28,8 @@ Angular.io is currently the preview site for Angular 2. This site also includes
|
|||
|
||||
`npm install -g browser-sync --msvs_version=2013`
|
||||
|
||||
3. run `gulp serve-and-watch`
|
||||
4. run `browser-sync start --proxy localhost:9000 --files "public/docs/**/*/**/*" --reloadDelay 500`
|
||||
5. browser will launch and stay refreshed automatically.
|
||||
3. run `gulp serve-and-sync`
|
||||
4. browser will launch ( on localhost:3000 instead of localhost:9000) and stay refreshed automatically.
|
||||
|
||||
## Technology Used
|
||||
- Angular 1.x: The production ready version of Angular
|
||||
|
|
44
gulpfile.js
44
gulpfile.js
|
@ -1,13 +1,12 @@
|
|||
var gulp = require('gulp');
|
||||
var watch = require('gulp-watch');
|
||||
var gutil = require('gulp-util');
|
||||
var Dgeni = require('dgeni');
|
||||
var path = require('path');
|
||||
var del = require('del');
|
||||
|
||||
var docShredder = require('./public/doc-shredder/doc-shredder');
|
||||
|
||||
var shredOptions = {
|
||||
var _shredOptions = {
|
||||
basePath: path.resolve('./public/docs'),
|
||||
sourceDir: "_examples",
|
||||
destDir: "_fragments"
|
||||
|
@ -21,32 +20,49 @@ a ‘partial’ shredder. It only shred’s files in directories changed during
|
|||
the current session.
|
||||
*/
|
||||
|
||||
gulp.task('serve-and-sync', function (cb) {
|
||||
execCommands(['harp server'], {}, cb);
|
||||
|
||||
gulp.task('shred-full', ['shred-clean'], function() {
|
||||
docShredder.shred( shredOptions);
|
||||
var browserSync = require('browser-sync').create();
|
||||
browserSync.init({
|
||||
proxy: 'localhost:9000',
|
||||
files: "public/docs/**/*/**/*",
|
||||
logFileChanges: true,
|
||||
reloadDelay: 500
|
||||
});
|
||||
|
||||
shredWatch(_shredOptions, function() {
|
||||
browserSync.reload();
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('serve-and-watch', function (cb) {
|
||||
var pattern = path.join(shredOptions.basePath, shredOptions.sourceDir, "**/*.*");
|
||||
|
||||
execCommands(['harp server'])
|
||||
|
||||
watch([ pattern], function(event, done) {
|
||||
console.log('Event type: ' + event.event); // added, changed, or deleted
|
||||
console.log('Event path: ' + event.path); // The path of the modified file
|
||||
docShredder.shredSingleDir(shredOptions, event.path);
|
||||
});
|
||||
execCommands(['harp server'], {}, cb);
|
||||
shredWatch(_shredOptions);
|
||||
});
|
||||
|
||||
gulp.task('shred-full', ['shred-clean'], function() {
|
||||
docShredder.shred( _shredOptions);
|
||||
});
|
||||
|
||||
gulp.task('shred-clean', function(cb) {
|
||||
var cleanPath = path.join(shredOptions.basePath, shredOptions.destDir, '**/*.*')
|
||||
var cleanPath = path.join(_shredOptions.basePath, _shredOptions.destDir, '**/*.*')
|
||||
del([ cleanPath, '!**/*.ovr.*'], function (err, paths) {
|
||||
// console.log('Deleted files/folders:\n', paths.join('\n'));
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
||||
function shredWatch(shredOptions, postShredAction) {
|
||||
var pattern = path.join(shredOptions.basePath, shredOptions.sourceDir, "**/*.*");
|
||||
watch([pattern], function (event, done) {
|
||||
console.log('Event type: ' + event.event); // added, changed, or deleted
|
||||
console.log('Event path: ' + event.path); // The path of the modified file
|
||||
docShredder.shredSingleDir(shredOptions, event.path).then(function () {
|
||||
postShredAction && postShredAction();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// added options are: shouldLog
|
||||
// cb is function(err, stdout, stderr);
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
"gulp-util": "^3.0.6",
|
||||
"gulp-watch": "^4.3.4",
|
||||
"lodash": "^3.10.1",
|
||||
"path": "^0.11.14"
|
||||
"path": "^0.11.14",
|
||||
"q": "^1.4.1"
|
||||
},
|
||||
"contributors": [
|
||||
"Jay Traband <jayt@ideablade.com>"
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
|
||||
// Canonical path provides a consistent path (i.e. always forward slashes) across different OSes
|
||||
var path = require('canonical-path');
|
||||
// var path = require('path');
|
||||
var Q = require('q');
|
||||
var del = require('del');
|
||||
// delPromise is a 'promise' version of del
|
||||
var delPromise = Q.denodeify(del);
|
||||
var Dgeni = require('dgeni');
|
||||
var _ = require('lodash');
|
||||
|
||||
|
@ -51,11 +52,10 @@ var shredSingleDir = function(shredOptions, filePath) {
|
|||
destDir: destDir
|
||||
}
|
||||
var cleanPath = path.join(shredOptions.basePath, destDir, '*.*')
|
||||
del([ cleanPath, '!**/*.ovr.*'], function (err, paths) {
|
||||
return delPromise([ cleanPath, '!**/*.ovr.*']).then(function(paths) {
|
||||
// console.log('Deleted files/folders:\n', paths.join('\n'));
|
||||
return shred(options);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Reference in New Issue