Skip to content

Method _isNativeScriptAppRoot always returns false if nativescript.config.ts is not inside app directory #22

Open
@CatchABus

Description

@CatchABus

First of all, let me point out that the master branch is not up-to-date. My report refers to latest version of plugin which uses feat/ns7 branch of this repo.

For few months now, NativeScript CLI has got --config parameter which allows you to define a path for a custom nativescript config file.
I removed old nativescript.config.ts and created a new one outside app root directory.

Usage example:
ns build android --config="../../myconfig/nativescript.config.ts"

So far so good. On the other hand, @nativescript/hook plugin will decide if current directory is the app root one by checking if nativescript.config.ts is present. For those who use a custom file inside another directory, this will be a problem as file will be missing.
As a result, my hooks will not be generated if I don't keep an empty dummy nativescript.config.ts inside my app root directory just to make sure _isNativeScriptAppRoot returns true.

This method decides if given directory is app root directory by looking for nativescript.config file.

function _isNativeScriptAppRoot(dir) {
  var tsConfig = path.join(dir, 'nativescript.config.ts');
  var jsConfig = path.join(dir, 'nativescript.config.js');
  if (fs.existsSync(tsConfig) || fs.existsSync(jsConfig)) {
    return true;
  }

  return false;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions