簡體   English   中英

永遠關注Grunt.js

[英]Grunt.js Watch Forever

目標:

我試圖在守護程序Gruntfile.js運行watch任務。

通常,我將執行以下腳本: grunt watch

Gruntfile.js:

module.exports = function(grunt) {

  grunt.initConfig({
    concat: {
      options: {
        separator: ''
      },
      dist: {
        src: ['static/js/**/*.js'],
        dest: 'app.js'
      }
    },
    watch: {
      files: ['<%= concat.dist.src %>'],
      tasks: ['concat']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
};

題:

我如何重生 grunt watch 作為一個守護進程?

更新:

似乎已經對此進行了考慮:
https://github.com/shama/grunt-hub#watching-forever
https://github.com/shama/grunt-hub/issues/3

您可以使用https://github.com/nodejitsu/forever exmaple

forever start gruntstart.js

gruntstart.js:

var exec = require('child_process').exec;

exec('grunt watch > log/grunt.log',
    function (error, stdout, stderr) {
        console.log('stdout: ' + stdout);
        console.log('stderr: ' + stderr);
        if (error !== null) {
           console.log('exec error: ' + error);
        }
});

我是javascript的新手,但我使用以下方法解決了此問題: tmux

  1. 一個窗格,用於執行git等簡單操作
  2. 其他是為了“ 咕unt手表

即使我關閉控制台, tmux也會繼續觀看:D
http://i.imgur.com/9L04OGe.jpg

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM