Skip to content

Commit 96380ea

Browse files
authored
feat: determine root by config existence (#21)
1 parent 7d3b471 commit 96380ea

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@ function findProjectDir(pkgdir) {
5151
}
5252

5353
function _isNativeScriptAppRoot(dir) {
54-
var isNativeScriptAppRoot = false;
55-
var packageJsonFile = path.join(dir, 'package.json');
56-
if (fs.existsSync(packageJsonFile)) {
57-
var packageJsonContent = require(packageJsonFile);
58-
isNativeScriptAppRoot = !!packageJsonContent.nativescript && !!packageJsonContent.nativescript.id;
54+
var tsConfig = path.join(dir, 'nativescript.config.ts');
55+
var jsConfig = path.join(dir, 'nativescript.config.js');
56+
if (fs.existsSync(tsConfig) || fs.existsSync(jsConfig)) {
57+
return true;
5958
}
6059

61-
return isNativeScriptAppRoot;
60+
return false;
6261
}
6362

6463
function forEachHook(pkgdir, callback) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/hook",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "Helper module for installing hooks into NativeScript projects",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)