index.js
function findRuntimePath() {
    const upPkg = readPkgUp.sync();
    // case 1: we're in NR itself
    if (upPkg.pkg.name === 'node-red') {
        if (checkSemver(upPkg.pkg.version,"<0.20.0")) {
            return path.join(path.dirname(upPkg.path), upPkg.pkg.main);
        } else {
            return path.join(path.dirname(upPkg.path),"packages","node_modules","node-red");
        }
    }
    // case 2: NR is resolvable from here
    try {
        return require.resolve('node-red');
    } catch (ignored) {}
    // case 3: NR is installed alongside node-red-node-test-helper
    if ((upPkg.pkg.dependencies && upPkg.pkg.dependencies['node-red']) ||
        (upPkg.pkg.devDependencies && upPkg.pkg.devDependencies['node-red'])) {
        const dirpath = path.join(path.dirname(upPkg.path), 'node_modules', 'node-red');
        try {
            const pkg = require(path.join(dirpath, 'package.json'));
            return path.join(dirpath, pkg.main);
        } catch (ignored) {}
    }
}
function findRuntimePath() {
    const upPkg = readPkgUp.sync();
    // case 1: we're in NR itself
    if (upPkg.pkg.name === 'node-red') {
        if (checkSemver(upPkg.pkg.version,"<0.20.0")) {
            return path.join(path.dirname(upPkg.path), upPkg.pkg.main);
        } else {
            return path.join(path.dirname(upPkg.path),"packages","node_modules","node-red");
        }
    }
    // case 2: NR is resolvable from here
    try {
        return require.resolve('node-red');
    } catch (ignored) {}
    // case 3: NR is installed alongside node-red-node-test-helper
    if ((upPkg.pkg.dependencies && upPkg.pkg.dependencies['node-red']) ||
        (upPkg.pkg.devDependencies && upPkg.pkg.devDependencies['node-red'])) {
        const dirpath = path.join(path.dirname(upPkg.path), 'node_modules', 'node-red');
        try {
            const pkg = require(path.join(dirpath, 'package.json'));
            return path.join(dirpath, pkg.main);
        } catch (ignored) {}
    }
}
function findRuntimePath ( ) { const upPkg = readPkgUp . sync ( ) ; // case 1: we're in NR itself if ( upPkg . pkg . name === 'node-red' ) { if ( checkSemver ( upPkg . pkg . version , "<0.20.0" ) ) { return path . join ( path . dirname ( upPkg . path ) , upPkg . pkg . main ) ; } else { return path . join ( path . dirname ( upPkg . path ) , "packages" , "node_modules" , "node-red" ) ; } } // case 2: NR is resolvable from here try { return require . resolve ( 'node-red' ) ; } catch ( ignored ) { } // case 3: NR is installed alongside node-red-node-test-helper if ( ( upPkg . pkg . dependencies && upPkg . pkg . dependencies [ 'node-red' ] ) || ( upPkg . pkg . devDependencies && upPkg . pkg . devDependencies [ 'node-red' ] ) ) { const dirpath = path . join ( path . dirname ( upPkg . path ) , 'node_modules' , 'node-red' ) ; try { const pkg = require ( path . join ( dirpath , 'package.json' ) ) ; return path . join ( dirpath , pkg . main ) ; } catch ( ignored ) { } } }
Finds the NR runtime path by inspecting environment
Finds the NR runtime path by inspecting environment