2014-07-16 4 views
2

내 nodeJS에 다음 스크립트가 있습니다.npm 스크립트를 쓸데없는 작업으로 변환하는 방법은 무엇입니까?

"scripts": { 
    "start": "grunt", 
    "test": "node --debug --harmony node_modules/grunt-cli/bin/grunt test" 
} 

노드 v0.11.13을 실행 중이므로 --harmony 플래그를 설정해야합니다. 내가 npm 테스트로 시작한다면 테스트는 제대로 구성되어 있지만, gruntfile에 모두 포함되어있는 것을 선호합니다. 서버를 시작하고 테스트를 실행하기 위해 무언가를 구성하는 방법이 있습니까?

답변

2

당신은 같은, 그 노드 플래그 꿀꿀 거리는 소리를 생성합니다 별칭 작업을 만들 수 있습니다 : 정말 grunt default debug:test

또는 조합 :

grunt.registerTask('debug', function() { 
    var done = this.async(); 
    // Specify tasks to run spawned 
    var tasks = Array.prototype.slice.call(arguments, 0); 
    grunt.util.spawn({ 
    // Use the existing node path 
    cmd: process.execPath, 
    // Add the flags and use process.argv[1] to get path to grunt bin 
    args: ['--debug', '--harmony', process.argv[1]].concat(tasks), 
    // Print everything this process is doing to the parent stdio 
    opts: { stdio: 'inherit' } 
    }, done); 
}); 

그런 다음 당신이 서버와 실행 테스트를 시작할 수 있습니다

  • grunt server test
  • grunt debug:server:test은 (봇을 실행 (노드 플래그없이 모두 실행) h와 노드 플래그).
관련 문제