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

Add yarn/npm install to readme on yarn condition #294

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions __tests__/readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,29 @@ describe('node:readme --no-coveralls and --generate-into', () => {
assert.noFileContent('other/README.md', 'coveralls');
});
});

describe('node:readme --yarn', () => {
beforeEach(() => {
return helpers
.run(require.resolve('../generators/readme'))
.withOptions({
name: 'my-project',
description: 'a cool project',
githubAccount: 'yeoman',
authorName: 'Yeoman',
authorUrl: 'http://yeoman.io',
yarn: true,
coveralls: false
})
.on('ready', gen => {
gen.fs.writeJSON(gen.destinationPath('package.json'), {
license: 'MIT'
});
});
});

it('creates and fills contents in README.md', () => {
assert.file('README.md');
assert.fileContent('README.md', '$ yarn add my-project');
});
});
1 change: 1 addition & 0 deletions generators/readme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ module.exports = class extends Generator {
},
license: pkg.license,
includeCoveralls: this.options.coveralls,
yarn: this.options.yarn,
content: this.options.content
}
);
Expand Down
4 changes: 4 additions & 0 deletions generators/readme/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ if (includeCoveralls) { %> [![Coverage percentage][coveralls-image]][coveralls-u
## Installation

```sh
<% if (yarn) { -%>
$ yarn add <%= projectName %>
<% } else { -%>
$ npm install --save <%= projectName %>
<% } -%>
```

## Usage
Expand Down