【发布时间】:2014-06-30 21:55:39
【问题描述】:
我确定我错过了一些简单的事情,但谁能在这里解释为什么 this.src.copy 发生在 this.dest.readJSON 之后:
var yeoman = require('yeoman-generator')
, TestGenerator
TestGenerator = yeoman.generators.Base.extend(
{ writing: function () {
this.src.copy('package.json', 'package.json')
this.pkg = this.dest.readJSON('package.json')
}
}
)
module.exports = TestGenerator
导致以下错误:
/tmp/test/node_modules/yeoman-generator/node_modules/file-utils/lib/file.js:252
throw new Error('Unable to read "' + filepath + '" file (Error code: ' + e
^
Error: Unable to read "/tmp/test-run/package.json" file (Error code: ENOENT).
at Env.File.read (/tmp/test/node_modules/yeoman-generator/node_modules/file-utils/lib/file.js:252:11)
at Env.(anonymous function) [as read] (/tmp/test/node_modules/yeoman-generator/node_modules/file-utils/lib/env.js:24:41)
at Env.File.readJSON (/tmp/test/node_modules/yeoman-generator/node_modules/file-utils/lib/file.js:258:18)
at Env.(anonymous function) [as readJSON] (/tmp/test/node_modules/yeoman-generator/node_modules/file-utils/lib/env.js:24:41)
at yeoman.generators.Base.extend.writing (/tmp/test/jim/index.js:7:28)
at /tmp/test/node_modules/yeoman-generator/lib/base.js:381:14
at processImmediate [as _immediateCallback] (timers.js:336:15)
我在任何一个文档中都找不到任何东西说这些函数不是同步的:
http://gruntjs.com/api/grunt.file https://github.com/SBoudrias/file-utils
【问题讨论】:
标签: javascript node.js gruntjs yeoman