Skip to content

Commit

Permalink
feat(create-astro): add --fancy flag (#5226)
Browse files Browse the repository at this point in the history
Co-authored-by: Nate Moore <nate@astro.build>
  • Loading branch information
natemoo-re and natemoo-re committed Oct 28, 2022
1 parent d7b27a1 commit 641b6d7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-feet-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Allow Windows users to pass `--fancy` to enable full unicode support
1 change: 1 addition & 0 deletions packages/create-astro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ May be provided in place of prompts
|:-------------|:----------------------------------------------------|
| `--template` | Specify the template name ([list][examples]) |
| `--commit` | Specify a specific Git commit or branch to use from this repo (by default, `main` branch of this repo will be used) |
| `--fancy` | For Windows users, `--fancy` will enable full unicode support |

### Debugging

Expand Down
2 changes: 1 addition & 1 deletion packages/create-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"tsconfigs"
],
"dependencies": {
"@astrojs/cli-kit": "^0.1.0",
"@astrojs/cli-kit": "^0.1.3",
"chalk": "^5.0.1",
"comment-json": "^4.2.3",
"execa": "^6.1.0",
Expand Down
10 changes: 8 additions & 2 deletions packages/create-astro/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint no-console: 'off' */
import { color, generateProjectName, label, say } from '@astrojs/cli-kit';
import { forceUnicode } from '@astrojs/cli-kit/utils';
import { random } from '@astrojs/cli-kit/utils';
import { assign, parse, stringify } from 'comment-json';
import { execa, execaCommand } from 'execa';
Expand Down Expand Up @@ -29,9 +30,14 @@ import { TEMPLATES } from './templates.js';
// broke our arg parser, since `--` is a special kind of flag. Filtering for `--` here
// fixes the issue so that create-astro now works on all npm version.
const cleanArgv = process.argv.filter((arg) => arg !== '--');
const args = yargs(cleanArgv);
const args = yargs(cleanArgv, { boolean: ['fancy']});
prompts.override(args);

// Enable full unicode support if the `--fancy` flag is passed
if (args.fancy) {
forceUnicode();
}

export function mkdirp(dir: string) {
try {
fs.mkdirSync(dir, { recursive: true });
Expand Down Expand Up @@ -99,7 +105,7 @@ export async function main() {
`${username}!`,
],
random(welcome),
]);
], { hat: args.fancy ? '🎩' : undefined });
await banner(version);
}

Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 641b6d7

Please sign in to comment.