Set up watching in Gruntfile
This commit is contained in:
parent
356dced85a
commit
000038a2bf
@ -34,12 +34,14 @@
|
|||||||
"globals": {
|
"globals": {
|
||||||
"afterEach": true,
|
"afterEach": true,
|
||||||
"beforeEach": true,
|
"beforeEach": true,
|
||||||
|
"console": true,
|
||||||
"define": true,
|
"define": true,
|
||||||
"describe": true,
|
"describe": true,
|
||||||
"expect": true,
|
"expect": true,
|
||||||
"it": true,
|
"it": true,
|
||||||
"jasmine": true,
|
"jasmine": true,
|
||||||
"module": true,
|
"module": true,
|
||||||
|
"process": true,
|
||||||
"require": true,
|
"require": true,
|
||||||
"requirejs": true,
|
"requirejs": true,
|
||||||
"spyOn": true,
|
"spyOn": true,
|
||||||
|
|||||||
@ -64,4 +64,6 @@ WORKDIR /opt/phantom-talk
|
|||||||
COPY package.json /opt/phantom-talk/package.json
|
COPY package.json /opt/phantom-talk/package.json
|
||||||
RUN ["npm", "install"]
|
RUN ["npm", "install"]
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
EXPOSE 8001
|
||||||
|
EXPOSE 35729
|
||||||
ENTRYPOINT ["npm"]
|
ENTRYPOINT ["npm"]
|
||||||
|
|||||||
66
Gruntfile.js
66
Gruntfile.js
@ -1,6 +1,7 @@
|
|||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var glob = require('glob');
|
var glob = require('glob');
|
||||||
var requireConfig = require('./assets/app/config');
|
var requireConfig = require('./assets/app/config');
|
||||||
|
var spawn = require('child_process').spawn;
|
||||||
|
|
||||||
function buildRequireConfig(options) {
|
function buildRequireConfig(options) {
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -67,7 +68,9 @@ module.exports = function (grunt) {
|
|||||||
|
|
||||||
clean: {
|
clean: {
|
||||||
app: './static/app',
|
app: './static/app',
|
||||||
compass: './sass-cache'
|
compass: './sass-cache',
|
||||||
|
karma: './karma-*',
|
||||||
|
tmp: './tmp-*.tmp'
|
||||||
},
|
},
|
||||||
|
|
||||||
compass: {
|
compass: {
|
||||||
@ -81,7 +84,18 @@ module.exports = function (grunt) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
karma: {unit: {configFile: 'config/test.js'}},
|
karma: {
|
||||||
|
server: {
|
||||||
|
configFile: 'config/test.js',
|
||||||
|
background: true
|
||||||
|
|
||||||
|
},
|
||||||
|
unit: {
|
||||||
|
configFile: 'config/test.js',
|
||||||
|
background: false,
|
||||||
|
singleRun: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
jshint: {
|
jshint: {
|
||||||
options: {jshintrc: './.jshintrc'},
|
options: {jshintrc: './.jshintrc'},
|
||||||
@ -96,20 +110,44 @@ module.exports = function (grunt) {
|
|||||||
jscs: {
|
jscs: {
|
||||||
src: ['Gruntfile.js', 'test/**/*.js'],
|
src: ['Gruntfile.js', 'test/**/*.js'],
|
||||||
options: {config: '.jscsrc'}
|
options: {config: '.jscsrc'}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
style: {
|
||||||
|
files: '<%= compass.dist.options.sassDir %>/**/*.scss',
|
||||||
|
tasks: ['compass'],
|
||||||
|
options: {livereload: true}
|
||||||
|
},
|
||||||
|
handlebars: {
|
||||||
|
files: './assets/**/*.hbs',
|
||||||
|
tasks: ['js'],
|
||||||
|
options: {livereload: true}
|
||||||
|
},
|
||||||
|
app: {
|
||||||
|
files: './assets/**/*.js',
|
||||||
|
tasks: ['js'],
|
||||||
|
options: {livereload: true}
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
files: './test/**/*.js',
|
||||||
|
tasks: ['test'],
|
||||||
|
options: {livereload: true}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerTask('test', ['jshint', 'jscs', 'karma']);
|
grunt.registerTask('run-deck', function () {
|
||||||
grunt.registerTask('dev', ['default']);
|
var deck = spawn('./bin/deck');
|
||||||
grunt.registerTask('style', ['compass', 'clean:compass']);
|
grunt.log.writeln('Running deck with pid: ' + deck.pid);
|
||||||
|
deck.stdout.pipe(process.stdout);
|
||||||
|
deck.stderr.pipe(process.stderr);
|
||||||
|
});
|
||||||
|
|
||||||
grunt.registerTask('default', [
|
grunt.registerTask('test', ['jshint', 'jscs', 'karma:unit', 'clean:karma']);
|
||||||
'clean:app',
|
grunt.registerTask('dev', ['default']);
|
||||||
'style',
|
grunt.registerTask('style', ['compass', 'clean:compass', 'clean:tmp']);
|
||||||
'handlebars',
|
grunt.registerTask('js', ['handlebars', 'copy', 'requirejs', 'test']);
|
||||||
'copy',
|
grunt.registerTask('build', ['clean:app', 'style', 'js', 'watch']);
|
||||||
'requirejs',
|
|
||||||
'jshint'
|
grunt.registerTask('default', ['run-deck', 'karma:server', 'build']);
|
||||||
]);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -19,5 +19,6 @@
|
|||||||
});
|
});
|
||||||
}(this));
|
}(this));
|
||||||
</script>
|
</script>
|
||||||
|
<script src="//localhost:35729/livereload.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
10
bin/deck
10
bin/deck
@ -9,6 +9,16 @@ var express = require('express');
|
|||||||
var app = express();
|
var app = express();
|
||||||
var staticHandler = express['static'].bind(express);
|
var staticHandler = express['static'].bind(express);
|
||||||
|
|
||||||
|
app.use((function log() {
|
||||||
|
var text = '{{date}} {{req.method}} {{req.url}}';
|
||||||
|
var logTemplate = handlebars.compile(text);
|
||||||
|
|
||||||
|
return function (req, res, next) {
|
||||||
|
console.log(logTemplate({date: new Date().toISOString(), req: req}));
|
||||||
|
next();
|
||||||
|
};
|
||||||
|
}()));
|
||||||
|
|
||||||
app.get('/', function index(req, res) {
|
app.get('/', function index(req, res) {
|
||||||
var indexFile = __dirname + '/../assets/index.html';
|
var indexFile = __dirname + '/../assets/index.html';
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ module.exports = function(config) {
|
|||||||
reporters: ['progress'],
|
reporters: ['progress'],
|
||||||
|
|
||||||
// web server port
|
// web server port
|
||||||
port: 8000,
|
port: 8001,
|
||||||
|
|
||||||
// enable / disable colors in the output (reporters and logs)
|
// enable / disable colors in the output (reporters and logs)
|
||||||
colors: true,
|
colors: true,
|
||||||
@ -47,7 +47,7 @@ module.exports = function(config) {
|
|||||||
|
|
||||||
// enable / disable watching file and executing tests
|
// enable / disable watching file and executing tests
|
||||||
// whenever any file changes
|
// whenever any file changes
|
||||||
autoWatch: false,
|
autoWatch: true,
|
||||||
|
|
||||||
// start these browsers
|
// start these browsers
|
||||||
// available browser launchers:
|
// available browser launchers:
|
||||||
@ -56,6 +56,6 @@ module.exports = function(config) {
|
|||||||
|
|
||||||
// Continuous Integration mode
|
// Continuous Integration mode
|
||||||
// if true, Karma captures browsers, runs the tests and exits
|
// if true, Karma captures browsers, runs the tests and exits
|
||||||
singleRun: true
|
singleRun: false
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -7,6 +7,6 @@ docker run \
|
|||||||
--interactive \
|
--interactive \
|
||||||
--tty \
|
--tty \
|
||||||
--volume $(abspath $dir/..):/opt/phantom-talk \
|
--volume $(abspath $dir/..):/opt/phantom-talk \
|
||||||
--publish=8000:8000 \
|
$port_args \
|
||||||
--entrypoint /bin/bash \
|
--entrypoint /bin/bash \
|
||||||
phantom-talk
|
phantom-talk
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
# vi: ft=sh
|
||||||
|
|
||||||
|
export port_args='--publish 8000:8000 --publish 8001:8001 --publish 35729:35729'
|
||||||
|
|
||||||
function abspath {
|
function abspath {
|
||||||
python -c 'import sys, os; print(os.path.abspath(sys.argv[1]))' "$1"
|
python -c 'import sys, os; print(os.path.abspath(sys.argv[1]))' "$1"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,6 @@ source $dir/common
|
|||||||
|
|
||||||
docker run \
|
docker run \
|
||||||
--volume $(abspath $dir/..):/opt/phantom-talk \
|
--volume $(abspath $dir/..):/opt/phantom-talk \
|
||||||
--publish 8000:8000 \
|
$port_args \
|
||||||
phantom-talk \
|
phantom-talk \
|
||||||
run dev
|
run dev
|
||||||
|
|||||||
@ -5,6 +5,6 @@ source $dir/common
|
|||||||
|
|
||||||
docker run \
|
docker run \
|
||||||
--volume $(abspath $dir/..):/opt/phantom-talk \
|
--volume $(abspath $dir/..):/opt/phantom-talk \
|
||||||
--publish 8000:8000 \
|
$port_args \
|
||||||
phantom-talk \
|
phantom-talk \
|
||||||
run deck
|
run deck
|
||||||
|
|||||||
@ -5,6 +5,6 @@ source $dir/common
|
|||||||
|
|
||||||
docker run \
|
docker run \
|
||||||
--volume $(abspath $dir/..):/opt/phantom-talk \
|
--volume $(abspath $dir/..):/opt/phantom-talk \
|
||||||
--publish 8000:8000 \
|
$port_args \
|
||||||
phantom-talk \
|
phantom-talk \
|
||||||
test
|
test
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user