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

findPackageJson in SwaggerManager.js loops infinitely when used in iron-node #40

Open
mik01aj opened this issue Aug 7, 2015 · 1 comment

Comments

@mik01aj
Copy link

mik01aj commented Aug 7, 2015

This is the function code:

    findPackageJson = function(startingDirectory) {
        if (!startingDirectory) {
            return false;
        }
        if (fs.existsSync(startingDirectory + '/package.json')) {
            return startingDirectory + '/package.json';
        }
        console.log(startingDirectory);
        return findPackageJson(startingDirectory.replace(/\/[^\/]+?$/g, ''));
    },

In my example, the startingDirectory is cli.js.

fs.existsSync(startingDirectory + '/package.json') is false, and then startingDirectory.replace(/\/[^\/]+?$/g, '') is cli.js again.

@mik01aj
Copy link
Author

mik01aj commented Aug 7, 2015

Btw, you don't need to rely on process.argv[1] (referenced above in SwaggerManager.js). See this page from docs:

the entry point of the current application can be obtained by checking require.main.filename.

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

1 participant