[英]Yeoman / grunt .readJSON()
我敢肯定我錯過了一些簡單的東西,但是誰能解釋為什么this.dest.readJSON之后發生this.src.copy:
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
看起來在復制的寫部分中可能正在運行一些異步代碼:
https://github.com/SBoudrias/file-utils/blob/master/lib/env.js#L129
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.