Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guess.js not compatible if angular is in nx workspace #561

Open
ElecTreeFrying opened this issue Jul 26, 2022 · 1 comment
Open

guess.js not compatible if angular is in nx workspace #561

ElecTreeFrying opened this issue Jul 26, 2022 · 1 comment

Comments

@ElecTreeFrying
Copy link

Need help on how to use guess.js with angular in nx workspace.

guess-parser/dist/guess-parser/index.js

    var path = ['package.json', '../package.json']
        .map(function (p) { return path_1.join(base, p); })
        .filter(fs_1.existsSync)
        .pop();
    if (!path) {
        throw new Error('Unable to discover the project type');
    }
    var content = JSON.parse(fs_1.readFileSync(path).toString());
    var exists = function (file) { return fs_1.existsSync(path_1.join(base, file)); };
    var d = dep(content);
    var dd = devDep(content);
    var tsconfig = 'tsconfig.app.json';
    var srcTsConfig = path_1.join('src', tsconfig);
    if (dd('@angular/cli') && (exists(srcTsConfig) || exists(tsconfig))) {

This line of code will always return false.
exists(srcTsConfig) || exists(tsconfig)

NX workspace file structure

- apps
--> my-project
----> tsconfig.app.json
- package.json
@tstackhouse
Copy link

tstackhouse commented Nov 3, 2022

I'm doing a little bit of tinkering with this, and I happen to be in an Nx workspace. It seems to work if I pass my app's tsconfig:

import { parseAngularRoutes } from 'guess-parser';

console.log(parseAngularRoutes('apps/my-app/tsconfig.app.json'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants