Skip to content

Commit 55f563f

Browse files
committed
refactor: make the code a little bit more concise
1 parent 40300e4 commit 55f563f

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

utils/generateReadme.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export default function generateReadme({
2525
needsVitest,
2626
needsEslint
2727
}) {
28+
const commandFor = (scriptName) => getCommand(packageManager, scriptName)
29+
2830
let readme = `# ${projectName}
2931
3032
This template should help get you started developing with Vue 3 in Vite.
@@ -42,19 +44,19 @@ See [Vite Configuration Reference](https://vitejs.dev/config/).
4244
`
4345

4446
let npmScriptsDescriptions = `\`\`\`sh
45-
${getCommand(packageManager, 'install')}
47+
${commandFor('install')}
4648
\`\`\`
4749
4850
### Compile and Hot-Reload for Development
4951
5052
\`\`\`sh
51-
${getCommand(packageManager, 'dev')}
53+
${commandFor('dev')}
5254
\`\`\`
5355
5456
### ${needsTypeScript ? 'Type-Check, ' : ''}Compile and Minify for Production
5557
5658
\`\`\`sh
57-
${getCommand(packageManager, 'build')}
59+
${commandFor('build')}
5860
\`\`\`
5961
`
6062

@@ -63,7 +65,7 @@ ${getCommand(packageManager, 'build')}
6365
### Run Unit Tests with [Vitest](https://vitest.dev/)
6466
6567
\`\`\`sh
66-
${getCommand(packageManager, 'test:unit')}
68+
${commandFor('test:unit')}
6769
\`\`\`
6870
`
6971
}
@@ -73,10 +75,7 @@ ${getCommand(packageManager, 'test:unit')}
7375
### Run Headed Component Tests with [Cypress Component Testing](https://on.cypress.io/component)
7476
7577
\`\`\`sh
76-
${getCommand(packageManager, 'test:unit')} # or \`${getCommand(
77-
packageManager,
78-
'test:unit:ci'
79-
)}\` for headless testing
78+
${commandFor('test:unit')} # or \`${commandFor('test:unit:ci')}\` for headless testing
8079
\`\`\`
8180
`
8281
}
@@ -86,11 +85,8 @@ ${getCommand(packageManager, 'test:unit')} # or \`${getCommand(
8685
### Run End-to-End Tests with [Cypress](https://www.cypress.io/)
8786
8887
\`\`\`sh
89-
${getCommand(packageManager, 'build')}
90-
${getCommand(packageManager, 'test:e2e')} # or \`${getCommand(
91-
packageManager,
92-
'test:e2e:ci'
93-
)}\` for headless testing
88+
${commandFor('build')}
89+
${commandFor('test:e2e')} # or \`${commandFor('test:e2e:ci')}\` for headless testing
9490
\`\`\`
9591
`
9692
}
@@ -104,13 +100,13 @@ ${getCommand(packageManager, 'test:e2e')} # or \`${getCommand(
104100
npx playwright install
105101
106102
# Runs the end-to-end tests
107-
${getCommand(packageManager, 'test:e2e')}
103+
${commandFor('test:e2e')}
108104
# Runs the tests only on Chromium
109-
${getCommand(packageManager, 'test:e2e -- --project=chromium')}
105+
${commandFor('test:e2e -- --project=chromium')}
110106
# Runs the tests of a specific file
111-
${getCommand(packageManager, 'test:e2e -- tests/example.spec.ts')}
107+
${commandFor('test:e2e -- tests/example.spec.ts')}
112108
# Runs the tests in debug mode
113-
${getCommand(packageManager, 'test:e2e -- --debug')}
109+
${commandFor('test:e2e -- --debug')}
114110
\`\`\`
115111
`
116112
}
@@ -120,7 +116,7 @@ ${getCommand(packageManager, 'test:e2e -- --debug')}
120116
### Lint with [ESLint](https://eslint.org/)
121117
122118
\`\`\`sh
123-
${getCommand(packageManager, 'lint')}
119+
${commandFor('lint')}
124120
\`\`\`
125121
`
126122
}

0 commit comments

Comments
 (0)