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

fix: make sure that name is always passed #25

Merged
merged 1 commit into from
May 9, 2018
Merged

Conversation

odinn1984
Copy link
Contributor

@odinn1984 odinn1984 commented May 9, 2018

When we can't get a project name from the lock file we pass the directory where the project file is as the project name.

@odinn1984 odinn1984 self-assigned this May 9, 2018
@odinn1984 odinn1984 force-pushed the fix/no_project_name branch 8 times, most recently from f62976d to e259652 Compare May 9, 2018 10:14
t.test('make sure project name is no-name', function (t) {
t.deepEqual(
result.package.name,
'snyk-php-plugin'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this pass? shouldn't it be 'no_project_name' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the cwd is the directory where the process is ran from (we run tap from the main project dir)

lib/composer.js Outdated
@@ -100,6 +99,10 @@ function generateJsonReport(
return data;
}

function getDefaultProjectName() {
return process.cwd().split(path.sep).pop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use also uses the root parameter passed to inspect(), as it's relative to the cwd

lib/composer.js Outdated
@@ -100,6 +101,10 @@ function generateJsonReport(
return data;
}

function getDefaultProjectName(manifestPath) {
return path.dirname(manifestPath).split(path.sep).pop();
Copy link
Contributor

@michael-go michael-go May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should use path.resolve (here or above) so that you get the full path, otherwise if user runs snyk test inside the php project, this code will result in the name '.'

lib/composer.js Outdated
@@ -75,10 +75,11 @@ function buildDependencies(
}

function generateJsonReport(
fileName, composerJsonObj, composerLockObj, systemVersions) {
fileName, composerJsonObj, composerLockObj, systemVersions, basePath) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would pass the basePath as first param, just before fileName

Copy link
Contributor

@michael-go michael-go left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍪

@odinn1984 odinn1984 merged commit e6c9dc4 into master May 9, 2018
@odinn1984 odinn1984 deleted the fix/no_project_name branch May 9, 2018 11:14
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

Successfully merging this pull request may close these issues.

None yet

2 participants