Skip to content

Commit e7a3f32

Browse files
committed
chore: override yarn command to make repo setup easier
Currently we need to run 'yarn bootstrap' to setup the repo. However it's easy to forget. This PR overrides the Yarn command to run the 'bootstrap' script if no arguments are specified.
1 parent 4359b83 commit e7a3f32

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

src/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ export default async function create(argv: yargs.Arguments<any>) {
366366
367367
{magenta {bold Get started} with the project}{gray :}
368368
369-
{gray $} yarn bootstrap
369+
{gray $} yarn
370370
${Object.entries(platforms)
371371
.map(
372372
([script, { name, color }]) => chalk`

templates/common/$.yarnrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Override Yarn command so we can automatically setup the repo on running `yarn`
2+
3+
yarn-path "scripts/bootstrap.js"

templates/common/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ We want this community to be friendly and respectful to each other. Please follo
44

55
## Development workflow
66

7-
To get started with the project, run `yarn bootstrap` in the root directory to install the required dependencies for each package:
7+
To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
88

99
```sh
10-
yarn bootstrap
10+
yarn
1111
```
1212

1313
While developing, you can run the [example app](/example/) to test your changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const path = require('path');
2+
const child_process = require('child_process');
3+
4+
const root = path.resolve(__dirname, '..');
5+
const args = process.argv.slice(2);
6+
const options = {
7+
cwd: process.cwd(),
8+
env: process.env,
9+
stdio: 'inherit',
10+
encoding: 'utf-8',
11+
};
12+
13+
let result;
14+
15+
if (process.cwd() !== root || args.length) {
16+
// We're not in the root of the project, or additional arguments were passed
17+
// In this case, forward the command to `yarn`
18+
result = child_process.spawnSync('yarn', args, options);
19+
} else {
20+
// If `yarn` is run without arguments, perform bootstrap
21+
result = child_process.spawnSync('yarn', ['bootstrap'], options);
22+
}
23+
24+
process.exitCode = result.status;

0 commit comments

Comments
 (0)