Node.js 更改grunt(express)/量角器调试端口 摘要
您好,我使用了Node.js 更改grunt(express)/量角器调试端口 摘要,node.js,express,gruntjs,protractor,Node.js,Express,Gruntjs,Protractor,您好,我使用了yeoman和angular fullstack来构建我项目的初始配置。不幸的是,angular fullstack不包含一个量角器包,我想用它作为我的端2端测试运行程序。所以我试着自己连接量角器 问题 虽然我成功地连接了量角器,但未能使其在调试模式下工作。问题是量角器和express都在同一个端口上启动了调试器5858,我发现没有办法允许更改这些端口 问题 如何使量角器和express调试器在不同的自定义端口上运行 附加信息 这是我的Gruntfile.js,我会根据要求发布更多
yeoman
和angular fullstack
来构建我项目的初始配置。不幸的是,angular fullstack
不包含一个量角器
包,我想用它作为我的端2端测试运行程序。所以我试着自己连接量角器
问题
虽然我成功地连接了量角器
,但未能使其在调试
模式下工作。问题是量角器
和express
都在同一个端口上启动了调试器5858
,我发现没有办法允许更改这些端口
问题
如何使量角器
和express
调试器在不同的自定义端口上运行
附加信息
这是我的Gruntfile.js,我会根据要求发布更多信息:
// Generated on 2014-04-27 using generator-angular-fullstack 1.4.2
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Define the configuration for all the tasks
grunt.initConfig({
// Project settings
yeoman: {
// configurable paths
app: require('./bower.json').appPath || 'app',
dist: 'dist'
},
express: {
options: {
debug: 5555,
port: process.env.PORT || 9000
},
dev: {
options: {
script: 'server.js',
debug: 7777
}
},
prod: {
options: {
script: 'dist/server.js',
node_env: 'production'
}
}
},
open: {
server: {
url: 'http://localhost:<%= express.options.port %>'
}
},
watch: {
js: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['newer:jshint:all'],
options: {
livereload: true
}
},
mochaTest: {
files: ['test/server/{,*/}*.js'],
tasks: ['env:test', 'mochaTest']
},
jsTest: {
files: ['test/client/spec/{,*/}*.js'],
tasks: ['newer:jshint:test', 'karma']
},
styles: {
files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
tasks: ['newer:copy:styles', 'autoprefixer']
},
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
files: [
'<%= yeoman.app %>/views/{,*//*}*.{html,jade}',
'{.tmp,<%= yeoman.app %>}/styles/{,*//*}*.css',
'{.tmp,<%= yeoman.app %>}/scripts/{,*//*}*.js',
'<%= yeoman.app %>/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
],
options: {
livereload: true
}
},
express: {
files: [
'server.js',
'lib/**/*.{js,json}'
],
tasks: ['newer:jshint:server', 'express:dev', 'wait'],
options: {
livereload: true,
nospawn: true //Without this option specified express won't be reloaded
}
}
},
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
server: {
options: {
jshintrc: 'lib/.jshintrc'
},
src: [ 'lib/{,*/}*.js']
},
all: [
'<%= yeoman.app %>/scripts/{,*/}*.js'
],
test: {
options: {
jshintrc: 'test/client/.jshintrc'
},
src: ['test/client/spec/{,*/}*.js']
}
},
// Empties folders to start fresh
clean: {
dist: {
files: [
{
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/*',
'!<%= yeoman.dist %>/.git*',
'!<%= yeoman.dist %>/Procfile'
]
}
]
},
heroku: {
files: [
{
dot: true,
src: [
'heroku/*',
'!heroku/.git*',
'!heroku/Procfile'
]
}
]
},
server: '.tmp'
},
// Add vendor prefixed styles
autoprefixer: {
options: {
browsers: ['last 1 version']
},
dist: {
files: [
{
expand: true,
cwd: '.tmp/styles/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
}
]
}
},
// Debugging with node inspector
'node-inspector': {
custom: {
options: {
'web-host': 'localhost'
}
}
},
// Use nodemon to run server in debug mode with an initial breakpoint
nodemon: {
debug: {
script: 'server.js',
options: {
nodeArgs: ['--debug-brk'],
env: {
PORT: process.env.PORT || 9000
},
callback: function (nodemon) {
nodemon.on('log', function (event) {
console.log(event.colour);
});
// opens browser on initial server start
nodemon.on('config:update', function () {
setTimeout(function () {
require('open')('http://localhost:8080/debug?port=5858');
}, 500);
});
}
}
}
},
// Automatically inject Bower components into the app
'bowerInstall': {
app: {
src: '<%= yeoman.app %>/views/index.html',
html: '<%= yeoman.app %>/views/index.html',
ignorePath: '<%= yeoman.app %>/'
}
},
// Renames files for browser caching purposes
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/public/scripts/{,*/}*.js',
'<%= yeoman.dist %>/public/styles/{,*/}*.css',
'<%= yeoman.dist %>/public/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%= yeoman.dist %>/public/styles/fonts/*'
]
}
}
},
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
html: ['<%= yeoman.app %>/views/index.html',
'<%= yeoman.app %>/views/index.jade'],
options: {
dest: '<%= yeoman.dist %>/public'
}
},
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
html: ['<%= yeoman.dist %>/views/{,*/}*.html',
'<%= yeoman.dist %>/views/{,*/}*.jade'],
css: ['<%= yeoman.dist %>/public/styles/{,*/}*.css'],
options: {
assetsDirs: ['<%= yeoman.dist %>/public']
}
},
// The following *-min tasks produce minified files in the dist folder
imagemin: {
options: {
cache: false
},
dist: {
files: [
{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg,gif}',
dest: '<%= yeoman.dist %>/public/images'
}
]
}
},
svgmin: {
dist: {
files: [
{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.svg',
dest: '<%= yeoman.dist %>/public/images'
}
]
}
},
htmlmin: {
dist: {
options: {
//collapseWhitespace: true,
//collapseBooleanAttributes: true,
//removeCommentsFromCDATA: true,
//removeOptionalTags: true
},
files: [
{
expand: true,
cwd: '<%= yeoman.app %>/views',
src: ['*.html', 'partials/**/*.html'],
dest: '<%= yeoman.dist %>/views'
}
]
}
},
// Allow the use of non-minsafe AngularJS files. Automatically makes it
// minsafe compatible so Uglify does not destroy the ng references
ngmin: {
dist: {
files: [
{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}
]
}
},
// Replace Google CDN references
cdnify: {
dist: {
html: ['<%= yeoman.dist %>/views/*.html']
}
},
// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [
{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>/public',
src: [
'*.{ico,png,txt}',
'.htaccess',
'bower_components/**/*',
'images/{,*/}*.{webp}',
'fonts/**/*'
]
},
{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>/views',
dest: '<%= yeoman.dist %>/views',
src: '**/*.jade'
},
{
expand: true,
cwd: '.tmp/images',
dest: '<%= yeoman.dist %>/public/images',
src: ['generated/*']
},
{
expand: true,
dest: '<%= yeoman.dist %>',
src: [
'package.json',
'server.js',
'lib/**/*'
]
}
]
},
styles: {
expand: true,
cwd: '<%= yeoman.app %>/styles',
dest: '.tmp/styles/',
src: '{,*/}*.css'
}
},
// Run some tasks in parallel to speed up the build process
concurrent: {
server: [
'copy:styles'
],
test: [
'copy:styles'
],
debug: {
tasks: [
'nodemon',
'node-inspector'
],
options: {
logConcurrentOutput: true
}
},
dist: [
'copy:styles',
'imagemin',
'svgmin',
'htmlmin'
]
},
// By default, your `index.html`'s <!-- Usemin block --> will take care of
// minification. These next options are pre-configured if you do not wish
// to use the Usemin blocks.
// cssmin: {
// dist: {
// files: {
// '<%= yeoman.dist %>/styles/main.css': [
// '.tmp/styles/{,*/}*.css',
// '<%= yeoman.app %>/styles/{,*/}*.css'
// ]
// }
// }
// },
// uglify: {
// dist: {
// files: {
// '<%= yeoman.dist %>/scripts/scripts.js': [
// '<%= yeoman.dist %>/scripts/scripts.js'
// ]
// }
// }
// },
// concat: {
// dist: {}
// },
// Test settings
karma: {
unit: {
configFile: 'karma.conf.js',
singleRun: true
}
},
mochaTest: {
options: {
reporter: 'spec'
},
src: ['test/server/**/*.js']
},
env: {
test: {
NODE_ENV: 'test'
}
}
});
// Used for delaying livereload until after server has restarted
grunt.registerTask('wait', function () {
grunt.log.ok('Waiting for server reload...');
var done = this.async();
setTimeout(function () {
grunt.log.writeln('Done waiting!');
done();
}, 500);
});
grunt.registerTask('express-keepalive', 'Keep grunt running', function () {
this.async();
});
grunt.registerTask('debug', function (target) {
debugger;
});
grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'express:prod', 'open', 'express-keepalive']);
}
if (target === 'debug') {
return grunt.task.run([
'clean:server',
'bowerInstall',
'concurrent:server',
'autoprefixer',
'concurrent:debug'
]);
}
grunt.task.run([
'clean:server',
'bowerInstall',
'concurrent:server',
'autoprefixer',
'express:dev',
'open',
'watch'
]);
});
grunt.registerTask('server', function () {
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
grunt.task.run(['serve']);
});
grunt.registerTask('test', function (target) {
if (target === 'server') {
return grunt.task.run([
'env:test',
'mochaTest'
]);
}
else if (target === 'client') {
return grunt.task.run([
'clean:server',
'concurrent:test',
'autoprefixer',
'karma'
]);
}
else grunt.task.run([
'test:server',
'test:client'
]);
});
grunt.registerTask('build', [
'clean:dist',
'bowerInstall',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'concat',
'ngmin',
'copy:dist',
'cdnify',
'cssmin',
'uglify',
'rev',
'usemin'
]);
grunt.registerTask('heroku', function () {
grunt.log.warn('The `heroku` task has been deprecated. Use `grunt build` to build for deployment.');
grunt.task.run(['build']);
});
grunt.registerTask('default', [
'newer:jshint',
'test',
'build'
]);
};
//于2014-04-27使用发电机角度全堆栈1.4.2生成
"严格使用",;
//#全球化
//出于性能原因,我们只降低了一个级别:
//'test/spec/{,*/}*.js'
//如果要递归匹配所有子文件夹,请使用此选项:
//“test/spec/***.js”
module.exports=函数(grunt){
//自动加载grunt任务
要求('load-grunt-tasks')(grunt);
//任务所需的时间。可以帮助优化构建时间
要求(“时间咕噜”)(咕噜);
//定义所有任务的配置
grunt.initConfig({
//项目设置
约曼:{
//可配置路径
app:require('./bower.json').appPath | |“app”,
dist:“dist”
},
快递:{
选项:{
电话:5555,
端口:process.env.port | 9000
},
开发人员:{
选项:{
脚本:“server.js”,
电话:7777
}
},
产品:{
选项:{
脚本:“dist/server.js”,
节点_env:'生产'
}
}
},
开放式:{
服务器:{
网址:'http://localhost:'
}
},
观察:{
js:{
文件:['/scripts/{,*/}*.js'],
任务:['newer:jshint:all'],
选项:{
利弗雷罗德:没错
}
},
莫切特:{
文件:['test/server/{,*/}*.js'],
任务:['env:test','mochaTest']
},
jsTest:{
文件:['test/client/spec/{,*/}*.js'],
任务:['newer:jshint:test','karma']
},
风格:{
文件:['/styles/{,*/}*.css'],
任务:[“更新的:复制:样式”,“自动引用器”]
},
Grunfile:{
文件:['grunfile.js']
},
利弗雷罗德:{
档案:[
“/views/{,*/*}*{html,jade}”,
“{.tmp,}/styles/{,*/*}*.css”,
“{.tmp,}/scripts/{,*/*}*.js”,
“/images/{,*/*}*{png,jpg,jpeg,gif,webp,svg}”
],
选项:{
利弗雷罗德:没错
}
},
快递:{
档案:[
'server.js',
'lib/***.{js,json}'
],
任务:['newer:jshint:server','express:dev','wait'],
选项:{
利弗雷罗德:没错,
nospawn:true//如果没有此选项,则不会重新加载指定的express
}
}
},
/确保代码风格达到标准,没有明显的错误。
jshint:{
选项:{
jshintrc:“.jshintrc”,
记者:require('jshint-style')
},
服务器:{
选项:{
jshintrc:'lib/.jshintrc'
},
src:['lib/{,*/}*.js']
},
全部:[
“/scripts/{,*/}*.js”
],
测试:{
选项:{
jshintrc:'test/client/.jshintrc'
},
src:['test/client/spec/{,*/}*.js']
}
},
//清空文件夹以重新开始
清洁:{
地区:{
档案:[
{
多特:没错,
src:[
“.tmp”,
'/*',
“!/.git*”,
“!/Procfile”
]
}
]
},
希罗库:{
档案:[
{
多特:没错,
src:[
“heroku/*”,
“!heroku/.git*”,
“!heroku/Procfile”
]
}
]
},
服务器:'.tmp'
},
//添加供应商前缀样式
自动刷新器:{
选项:{
浏览器:[“上一版本”]
},
地区:{
档案:[
{
是的,
cwd:“.tmp/styles/”,
src:'{,*/}*.css',,
目标:'.tmp/styles/'
}
]
}
},
//使用节点检查器进行调试
“节点检查器”:{
自定义:{
选项:{
“web主机”:“本地主机”
}
}
},
//使用nodemon在调试模式下以初始bre运行服务器
express: {
options: {
port: process.env.PORT || 9000
},
dev: {
options: {
script: 'server/app.js',
debug: 5859
}
},
prod: {
options: {
script: 'dist/server/app.js'
}
}
},