Repository navigation
Expand file tree
/
Copy pathGulpfile.js
More file actions
115 lines (100 loc) · 3.16 KB
/
Copy pathGulpfile.js
File metadata and controls
115 lines (100 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
var gulp = require('gulp');
var concat = require('gulp-concat');
var coffee = require('gulp-coffee');
var docco = require('gulp-docco');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var lazypipe= require('lazypipe');
var taskList= require('gulp-task-listing');
var exec = require('child_process').exec;
var ASNames = 'util evented color colormaps colormixin shapes agentset patch patches turtle turtles link links model animator'.split(' ');
var ASPaths = ASNames.map(function(n){return 'src/'+n+'.coffee';});
// Create "macro" pipes. Note 'pipe(name,args)' not 'pipe(name(args))'
// https://github.com/OverZealous/lazypipe
var jsTasks = lazypipe() // write .js and .min.js into lib/
.pipe(gulp.dest, 'lib/')
.pipe(rename, {suffix: '.min'})
.pipe(uglify)
.pipe(gulp.dest, 'lib/');
var coffeeTasks = lazypipe()
.pipe(coffee)
.pipe(jsTasks);
gulp.task('all', ['build', 'docs', 'models']);
// Build tasks:
gulp.task('build-agentscript', function () {
return gulp.src(ASPaths)
.pipe(concat('agentscript.coffee'))
.pipe(coffeeTasks());
});
gulp.task('build-extras-cs', function () {
return gulp.src('extras/*.coffee')
.pipe(coffeeTasks());
});
gulp.task('build-extras-js', function () {
return gulp.src('extras/*.js')
.pipe(jsTasks());
});
gulp.task('build-extras', ['build-extras-cs','build-extras-js']);
gulp.task('build', ['build-agentscript', 'build-extras']);
// Watch tasks
gulp.task('watch', function() {
gulp.watch(ASPaths, ['build-agentscript']);
gulp.watch('extras/*.js', function(event) {
console.log(event);
gulp.src(event.path)
.pipe(jsTasks());
});
gulp.watch('extras/*.coffee', function(event) {
console.log(event);
gulp.src(event.path)
.pipe(coffeeTasks());
});
gulp.watch('models/*.coffee', ['models']);
// function(event) {
// console.log(event);
// gulp.src(event.path)
// .pipe(coffee)
// .gulp.pipe(gulp.dest('models'))
// });
});
// Build any models not embedded in html file:
gulp.task('models', function() {
return gulp.src('./models/*.coffee')
.pipe(coffee())
.pipe(gulp.dest('./models/'));
});
// Documentation tasks
gulp.task('docs', function() {
return gulp.src(["src/*coffee", "extras/*.{coffee,js}", "models/template.coffee"])
.pipe(docco())
.pipe(gulp.dest('docs/'));
});
// Git tasks: we mainly have these to avoid gh-pages conflicts
// gulp.task('git:prep', )
// Default: list out tasks
gulp.task('default', taskList);
var cb = function (err) {
if (err) console.log("cb: ", err);
}
gulp.task('test', function (cb) { // cb() insures async
exec('ping -c1 localhost; pwd', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
if (err) return cb(err);
});
})
/*
Notes:
- coffee: add sourcemaps?
Doesn't have the Generated by CoffeeScript 1.7.1 comment
- add jsHint?
- node_modules/.bin/gulp
- why-do-we-need-to-install-gulp-globally-and-locally http://goo.gl/OhdWvO
- http://substack.net/task_automation_with_npm_run
- agentscript watch can report event like so:
var watcher = gulp.watch(ASPaths, ['build-agentscript']);
watcher.on('change', function(event) {
console.log(event);
});
-or-
*/