@@ -24,29 +24,42 @@ function generateHookName(pkg, hook) {
2424}
2525
2626function findProjectDir ( pkgdir ) {
27- if ( process . env . INIT_CWD ) {
27+ if ( process . env . INIT_CWD && _isNativeScriptAppRoot ( process . env . INIT_CWD ) ) {
2828 return process . env . INIT_CWD ;
2929 }
3030
3131 var candidateDir = pkgdir ;
32+ var oldCandidateDir = null ;
3233
3334 while ( true ) {
34- var oldCandidateDir = candidateDir ;
3535 candidateDir = path . dirname ( candidateDir ) ;
36+ if ( oldCandidateDir === candidateDir ) {
37+ return ;
38+ }
39+
3640 if ( path . basename ( candidateDir ) === 'node_modules' ) {
3741 continue ;
3842 }
39- var packageJsonFile = path . join ( candidateDir , 'package.json' ) ;
40- if ( fs . existsSync ( packageJsonFile ) ) {
43+
44+ if ( _isNativeScriptAppRoot ( candidateDir ) ) {
4145 return candidateDir ;
4246 }
4347
44- if ( oldCandidateDir === candidateDir ) {
45- return ;
46- }
48+ oldCandidateDir = candidateDir ;
4749 }
4850}
4951
52+ function _isNativeScriptAppRoot ( dir ) {
53+ var isNativeScriptAppRoot = false ;
54+ var packageJsonFile = path . join ( dir , 'package.json' ) ;
55+ if ( fs . existsSync ( packageJsonFile ) ) {
56+ var packageJsonContent = require ( packageJsonFile ) ;
57+ isNativeScriptAppRoot = ! ! packageJsonContent . nativescript && ! ! packageJsonContent . nativescript . id ;
58+ }
59+
60+ return isNativeScriptAppRoot ;
61+ }
62+
5063function forEachHook ( pkgdir , callback ) {
5164 var pkg = require ( path . join ( pkgdir , 'package.json' ) ) ;
5265 var ns = pkg . nativescript ;
0 commit comments