Skip to content

Commit

Permalink
Simplify changeset and move line into the notify() function
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Lamb committed Sep 5, 2023
1 parent 523d7f4 commit b075b65
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .changeset/friendly-clocks-act.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
'create-astro': patch
'@astrojs/telemetry': patch
'astro': patch
---

Support detecting Bun when logging messages with package manager information
Support detecting Bun when logging messages with package manager information.
5 changes: 1 addition & 4 deletions packages/astro/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import * as colors from 'kleur/colors';
import yargs from 'yargs-parser';
import { ASTRO_VERSION } from '../core/constants.js';
import whichPm from 'which-pm';

type CLICommand =
| 'help'
Expand Down Expand Up @@ -128,10 +127,8 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
process.env.NODE_ENV = cmd === 'dev' ? 'development' : 'production';
}

const packageManager = (await whichPm(process.cwd())).name ?? 'npm';

const { notify } = await import('./telemetry/index.js');
await notify(packageManager);
await notify();

// These commands uses the logging and user config. All commands are assumed to have been handled
// by the end of this switch statement.
Expand Down
5 changes: 4 additions & 1 deletion packages/astro/src/cli/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
import type yargs from 'yargs-parser';
import * as msg from '../../core/messages.js';
import { telemetry } from '../../events/index.js';
import whichPm from 'which-pm';

interface TelemetryOptions {
flags: yargs.Arguments;
}

export async function notify(packageManager = 'npm') {

export async function notify() {
const packageManager = (await whichPm(process.cwd())).name ?? 'npm';
await telemetry.notify(() => {
console.log(msg.telemetryNotice(packageManager) + '\n');
return true;
Expand Down

0 comments on commit b075b65

Please sign in to comment.