我想通过终端从gruntfile获取已注册的任务。
示例:
grunt.registerTask('test', ['clean', 'compass', 'uglify', 'cssmin', 'imagemin', 'copy:test', 'ftp-deploy:test', 'clean']);
然后在终端上我会输入类似
的内容$> grunt --listtasks
如果我能用这样的描述注册每个任务,那就更好了:
grunt.registerTask('test', 'this task deploys to testserver',['clean', 'compass', 'uglify', 'cssmin', 'imagemin', 'copy:test', 'ftp-deploy:test', 'clean']);
然后输出可能是:
$> test: this task deploys to testserver (clean, compass, uglify, cssmin, imagemin, copy:test, ftp-deploy:test, clean)
答案 0 :(得分:1)
运行grunt --help
以获取所有已注册任务的列表。这显示了命令和任务描述。示例输出:
$ grunt --help
Grunt: The JavaScript Task Runner (v0.4.1)
Usage
grunt [options] [task [task ...]]
Options
--help, -h Display this help text.
--base Specify an alternate base path. By default, all file paths
are relative to the Gruntfile. (grunt.file.setBase) *
--no-color Disable colored output.
--gruntfile Specify an alternate Gruntfile. By default, grunt looks in
the current or parent directories for the nearest
Gruntfile.js or Gruntfile.coffee file.
--debug, -d Enable debugging mode for tasks that support it.
--stack Print a stack trace when exiting with a warning or fatal
error.
--force, -f A way to force your way past warnings. Want a suggestion?
Don't use this option, fix your code.
--tasks Additional directory paths to scan for task and "extra"
files. (grunt.loadTasks) *
--npm Npm-installed grunt plugins to scan for task and "extra"
files. (grunt.loadNpmTasks) *
--no-write Disable writing files (dry run).
--verbose, -v Verbose mode. A lot more information output.
--version, -V Print the grunt version. Combine with --verbose for more
info.
--completion Output shell auto-completion rules. See the grunt-cli
documentation for more information.
Options marked with * have methods exposed via the grunt API and should instead
be specified inside the Gruntfile wherever possible.
Available tasks
rosetta Shared variables between JS and CSS. *
asciify Ascii awesomizer. A Grunt task for better banners and hot
logs. *
clear Clear your terminal window
clean Clean files and folders. *
concat Concatenate files. *
jshint Validate files with JSHint. *
sass Compile Sass to CSS *
watch Run predefined tasks whenever watched files change.
csso Minify CSS files with CSSO. *
lintspaces Checking spaces *
newer Run a task with only those source files that have been
modified since the last successful run.
any-newer Run a task with all source files if any have been modified
since the last successful run.
newer-timestamp Internal task.
svgmin Minify SVG *
trimtrailingspaces Removing the trailing spaces *
webfont Compile separate SVG files to webfont *
Tasks run in the order specified. Arguments may be passed to tasks that accept
them by using colons, like "lint:files". Tasks marked with * are "multi tasks"
and will iterate over all sub-targets if no argument is specified.
The list of available tasks may change based on tasks directories or grunt
plugins specified in the Gruntfile or via command-line options.
For more information, see http://gruntjs.com/
答案 1 :(得分:1)