diff --git a/change/rnpm-plugin-windows-2019-12-16-13-38-43-nugetver.json b/change/rnpm-plugin-windows-2019-12-16-13-38-43-nugetver.json new file mode 100644 index 00000000000..68b02ae939b --- /dev/null +++ b/change/rnpm-plugin-windows-2019-12-16-13-38-43-nugetver.json @@ -0,0 +1,8 @@ +{ + "type": "patch", + "comment": "CLI detect project name from app.json", + "packageName": "rnpm-plugin-windows", + "email": "licanhua@live.com", + "commit": "ed24ef5033bac55fb8f0db6ee727051521e4682c", + "date": "2019-12-16T21:38:43.643Z" +} \ No newline at end of file diff --git a/current/local-cli/rnpm/windows/src/common.js b/current/local-cli/rnpm/windows/src/common.js index d3b8936861d..a48dc4275de 100644 --- a/current/local-cli/rnpm/windows/src/common.js +++ b/current/local-cli/rnpm/windows/src/common.js @@ -122,7 +122,17 @@ const getReactNativeVersion = function () { const getReactNativeAppName = function () { console.log('Reading application name from package.json...'); - return JSON.parse(fs.readFileSync('package.json', 'utf8')).name; + let name = JSON.parse(fs.readFileSync('package.json', 'utf8')).name; + if (!name) { + if (fs.existsSync('app.json')) { + console.log('Reading application name from app.json...'); + name = JSON.parse(fs.readFileSync('app.json', 'utf8')).name; + } + } + if (!name) { + console.error('Please specify name in package.json or app.json'); + } + return name; }; /**