Skip to content

Commit

Permalink
🐛 Don't suggest install default value when project is not a js project (
Browse files Browse the repository at this point in the history
  • Loading branch information
kefranabg committed Nov 1, 2019
1 parent 5ec2ce4 commit 672d591
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/project-infos.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const getProjectInfos = async () => {
const spinner = ora('Gathering project infos').start()

const packageJson = await getPackageJson()
const isJSProject = !!packageJson
const name = getProjectName(packageJson)
const description = get(packageJson, 'description', undefined)
const engines = get(packageJson, 'engines', undefined)
Expand Down Expand Up @@ -169,7 +170,8 @@ const getProjectInfos = async () => {
documentationUrl,
isGithubRepos,
usage,
testCommand
testCommand,
isJSProject
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/project-infos.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe('projectInfos', () => {
documentationUrl:
'https://github.com/kefranabg/readme-md-generator#readme',
isGithubRepos: true,
isJSProject: true,
usage: undefined,
testCommand: undefined
})
Expand Down Expand Up @@ -134,6 +135,7 @@ describe('projectInfos', () => {
licenseUrl: undefined,
documentationUrl: undefined,
isGithubRepos: false,
isJSProject: true,
usage: undefined,
testCommand: undefined
})
Expand Down Expand Up @@ -165,6 +167,7 @@ describe('projectInfos', () => {
documentationUrl:
'https://github.com/kefranabg/readme-md-generator#readme',
isGithubRepos: true,
isJSProject: false,
usage: undefined,
testCommand: undefined
})
Expand Down Expand Up @@ -193,6 +196,7 @@ describe('projectInfos', () => {
licenseUrl: undefined,
documentationUrl: undefined,
isGithubRepos: false,
isJSProject: false,
usage: undefined,
testCommand: undefined
})
Expand Down Expand Up @@ -221,6 +225,7 @@ describe('projectInfos', () => {
licenseUrl: undefined,
documentationUrl: undefined,
isGithubRepos: false,
isJSProject: false,
usage: undefined,
testCommand: undefined
})
Expand Down Expand Up @@ -274,6 +279,7 @@ describe('projectInfos', () => {
documentationUrl:
'https://github.com/kefranabg/readme-md-generator#readme',
isGithubRepos: true,
isJSProject: true,
usage: undefined,
testCommand: undefined
})
Expand Down Expand Up @@ -331,6 +337,7 @@ describe('projectInfos', () => {
documentationUrl:
'https://github.com/kefranabg/readme-md-generator#readme',
isGithubRepos: true,
isJSProject: true,
usage: undefined,
testCommand: undefined
})
Expand Down
4 changes: 2 additions & 2 deletions src/questions/install-command.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = () => ({
module.exports = projectInfos => ({
type: 'input',
message: '📦 Install command (use empty value to skip)',
name: 'installCommand',
default: 'npm install'
default: projectInfos.isJSProject ? 'npm install' : undefined
})
17 changes: 15 additions & 2 deletions src/questions/install-command.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const askInstallCommand = require('./install-command')

describe('askInstallCommand', () => {
it('should return correct question format', () => {
const result = askInstallCommand()
it('should return correct question format when project lang is js', () => {
const projectInfos = { isJSProject: true }
const result = askInstallCommand(projectInfos)

expect(result).toEqual({
type: 'input',
Expand All @@ -11,4 +12,16 @@ describe('askInstallCommand', () => {
default: 'npm install'
})
})

it('should return correct question format when project lang is js', () => {
const projectInfos = { isJSProject: false }
const result = askInstallCommand(projectInfos)

expect(result).toEqual({
type: 'input',
message: '📦 Install command (use empty value to skip)',
name: 'installCommand',
default: undefined
})
})
})

0 comments on commit 672d591

Please sign in to comment.