node.js - Gruntjs with grunt-nodemon, watch and jshint -
I'm trying to run GruntJS with those 3 plugins so that these changes and the first To see: Lint the file and then reload the Express server My problem with the configuration given below is that if jshint lint file does not run nodemon and its Adverse.
// Gruntfile .js // Our wrapper function (required by the bell and its plugin) // All the configuration module inside this function. Exports = function (grunt) {// ========================================= ================================== CONFIGURE GRUNT ============= ================================================== ================================================== ====================== Strength .initConfig ({// Get package information from package.Jason ------------- --------------- // In this way we can use things like name and version (pkg.name) pkg: grunt.file.readJSON ('package.json'), // All our configurations go here // Configure jshint to validate jsint file --------- ---------------------- ---- jshint: {option: {reporter Required: (jshint-stylish) // jshint-stylish to make use of our errors k and read better}, // When this task is run, grantfile and all JS files do the source creation: ['Grunfile.js', 'path / * .js']}, see: {// For scripts, run Jshint and uglify scripts: {files: 'routes / * .js', Tasks: ['jshint'] }} Concurrently: {dev: {function: [jshint ',' nodemon ',' watch '], option: {LogConcurrentOutput: true}}}, // concurrent nodomon: {dev: {script:' .server. Js'}} // nodemon}); // ================================================ ============================ Load Grunts Plugins =================== ================================================== ================================================== ============ We can load these if they are in our package. Json // Make sure you have installed NPM so our app these grunt.load NMM Tasks ('Grunt-Contributed -JSHint'); Grunt.loadNpmTasks ('grunting-contribution-watch'); Grunt.loadNpmTasks ('grunge-nodemon'); Grunt.registerTask ('default', '', function () {var agenda = ['jshint', 'nodemon', 'watch']; grunt.task.run (taskList);}); };
Edit (explanation):
The first time I ran the files ghurghur
, jshint , then The start of nodomon and jshint is no longer connected.
Output:
Running "Default" function running "jshint: build" (Jshint) function ✔︎ No problem is running "nodemon: Dev "(nodemon) v1.2.1 [nodemon] to restart at any time, enter` rs` [nodemon]: *. * [Nodemon] listening to the "server / js / express server" on the node start port server
Try it to run as a function function:
grunt.registerTask ('default', '', function () {var taskList = ['jshint', 'nodemon' 'Watch']; grunt.task.run (task list);});
EDIT: Using the grunt-express-server
applied to your setup, I have another method to achieve the goal of auto-rearings with express Used:
module.exports = function (grunt) {grunt.initConfig ({pkg: grunt.file.readJSON ("package.json"), see: {express: {files ['Routes / * .js'], function: [' jshint ',' express: dev '], option: {spawn: false}}}, express: {dev: {options: {script:' app .js',}}}, Jshint: {options: {node: true}, all: {src: ['routes / *. Js']}}}); Grunt.loadNpmTasks ('grunge-express-server'); Grunt.loadNpmTasks ('Grunt-Contributing-JSHint'); Grunt.registerTask ('default', '', function () {var taskList = ['jshint', 'express: dev', 'watch']; grunt.task.run (taskList);}); };
Comments
Post a Comment