Grunt任务不会在Windows上继续

时间:2014-09-09 13:24:01

标签: javascript windows node.js macos gruntjs

Grunt任务无法在Windows上继续。

嗨!那里。

我有疑问如何在Windows上使用grunt。 我一直在Mac和Windows上通过grunt任务使用指南针,监视和sftp-deploy。

Mac的结果如下。

Completed in 8.849s at Tue Sep 09 2014 18:04:52 GMT+0900 (JST) - Waiting...
>> File "sass/hiratsuka29.scss" added.
Running "compass:dist" (compass) task
write stylesheets/hiratsuka29.css (0.746s)

Running "sftp-deploy:build" (sftp-deploy) task
>> Logging in with key at /Users/shhirats/shhirats/shhirats_secure.key
>> Concurrency : 4
transferred=[3/46] elapsed=[0.2s] overall=[7%] eta=[2.3s] [=== ]>>
Directories done.
transferred=[4/46] elapsed=[0.4s] overall=[9%] eta=[3.8s] [=== ]>>
Transferred : 0.001953125 Mb

Done, without errors.

等待......

Grunt任务一直在Mac上继续。

Windows结果如下。

C:\gittmp7\ShiftCustomer\ShiftCustomer\ShiftCustomer\public\assets>grunt
Running "watch" task
Waiting...
>> File "scss\sm\part\work-list.scss" changed.
Running "compass:dist" (compass) task
unchanged img/sm/sprites-s2c9a5e2425.png
unchanged img/sm/icon-sa7be2049da.png
   write css/sm/part/work-list.css (2.976s)

Running "sftp-deploy:build" (sftp-deploy) task
>> Logging in with key at C:\ssh\key\shinya.key
>> Concurrency : 4
  transferred=[1/16] elapsed=[0.0s] overall=[6%] eta=[0.0s] [=                ]
  transferred=[2/16] elapsed=[0.1s] overall=[13%] eta=[0.6s] [==              ]
  transferred=[3/16] elapsed=[0.2s] overall=[19%] eta=[0.7s] [===              ]
  transferred=[4/16] elapsed=[0.2s] overall=[25%] eta=[0.7s] [====            ]
  transferred=[5/16] elapsed=[0.3s] overall=[31%] eta=[0.7s] [=====            ]
  transferred=[6/16] elapsed=[0.4s] overall=[38%] eta=[0.7s] [======          ]
>> Directories done.
  transferred=[7/16] elapsed=[0.7s] overall=[44%] eta=[0.8s] [=======          ]
  transferred=[8/16] elapsed=[0.7s] overall=[50%] eta=[0.7s] [=========        ]
>> Transferred : 0.072265625 Mb
 Running "watch" task
 Completed in 6.506s at Tue Sep 09 2014 18:11:18 GMT+0900 (東京 (標準時)) - Waiti
 ng...
>> Transferred : 0.072265625 Mb
 Running "compass:dist" (compass) task

 Running "sftp-deploy:build" (sftp-deploy) task
>> Logging in with key at C:\ssh\key\shinya.key
>> Concurrency : 4
  transferred=[1/16] elapsed=[0.0s] overall=[6%] eta=[0.0s] [=                ]
  transferred=[2/16] elapsed=[0.1s] overall=[13%] eta=[0.5s] [==              ]
  transferred=[3/16] elapsed=[0.2s] overall=[19%] eta=[0.7s] [===              ]
  transferred=[4/16] elapsed=[0.2s] overall=[25%] eta=[0.7s] [====            ]
  transferred=[5/16] elapsed=[0.3s] overall=[31%] eta=[0.7s] [=====            ]
  transferred=[6/16] elapsed=[0.4s] overall=[38%] eta=[0.6s] [======          ]
>> Directories done.
>> Transferred : 0 Mb
 Done, without errors.

C:\ gittmp7 \ ShiftCustomer \ ShiftCustomer \ ShiftCustomer \ public \ assets>

Grunt任务已经移动了两次,然后Grunt任务在Windows上完成。

为什么grunt任务会在Windows上执行两次? 为什么grunt任务在Windows上完成?

请教它。 谢谢。

1 个答案:

答案 0 :(得分:0)

我忘记了Gruntfile.js

    module.exports = function(grunt){

  pkg: grunt.file.readJSON('package.json'),  //package.jsonを取得
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-open');
  grunt.loadNpmTasks('grunt-sftp-deploy');

  grunt.initConfig({      //grunt.initConfigの中にタスクの設定を記述する
    // options
    options: {
      livereload: true,
      nospawn: true
    },
    compass: {
      dist: {
        options: {                
          config: 'config.rb'
        }
      }
    },
    watch: {
  options: {
        spawn: false
      },
      styles: {
        files: [
        'sass/*',
        'sass/sm/part/*'
        ],   //監視するファイルを指定(sassフォルダのscssファイル全て)
        tasks: ['compass','sftp-deploy']   //指定したファイルが変更された場合行うタスク(sassのコンパイルをする)
      }
    },
    // Live Reload
    connect: {
      livereload: {
        options: {
          port: 80
        }
      }
    },
    // gruntコマンド実行時にページをブラウザで開く
    open: {
      server: {
        path: 'http://indival.yahoo.co.jp:<%= connect.livereload.options.port %>'
      }
    },
    'sftp-deploy': {
      build: {
        auth: {
          host: 'dev.idv.portal.vallabo.info',
          port: 22,
          authKey: 'shhirats_user'
        },
        cache: 'sftpCache.json',
        src: 'stylesheets',
        dest: '/home/shhirats',
        serverSep: '/',
        concurrency: 4,
        progress: true
      }
    }
  });

  grunt.registerTask('default', ['watch','compass','sftp-deploy']);

};

我在Windows和Mac上使用它。