Skip to content

Commit f0fe24d

Browse files
authored
Merge pull request #583 from underctrl-io/fix-deno-cmd
fix: handle known deno templates
2 parents 518b619 + f25b4fa commit f0fe24d

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

packages/create-commandkit/src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ Examples:
132132
process.exit(1);
133133
}
134134

135-
// Determine package manager
136-
const manager = resolvePackageManager(cliOptions);
137-
138135
// Get Discord token
139136
let token: string;
140137
if (cliOptions.yes) {
@@ -158,9 +155,13 @@ Examples:
158155

159156
outro(colors.cyan('Setup complete.'));
160157

158+
const example = cliOptions.example || getDefaultExample(cliOptions);
159+
160+
// Determine package manager
161+
const manager = resolvePackageManager(cliOptions, example);
162+
161163
// Fetch example from GitHub
162164
try {
163-
const example = cliOptions.example || getDefaultExample(cliOptions);
164165
await fetchExample({
165166
example,
166167
examplePath: cliOptions.examplePath,

packages/create-commandkit/src/utils.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@ export function getPackageManagerFromCLI(options: {
3434
return null;
3535
}
3636

37-
export function resolvePackageManager(cliOptions: {
38-
useNpm?: boolean;
39-
usePnpm?: boolean;
40-
useYarn?: boolean;
41-
useBun?: boolean;
42-
useDeno?: boolean;
43-
}): PackageManager {
37+
export function resolvePackageManager(
38+
cliOptions: {
39+
useNpm?: boolean;
40+
usePnpm?: boolean;
41+
useYarn?: boolean;
42+
useBun?: boolean;
43+
useDeno?: boolean;
44+
},
45+
name: string,
46+
): PackageManager {
4447
const cliManager = getPackageManagerFromCLI(cliOptions);
45-
return cliManager || detectPackageManager();
48+
return cliManager || (isDenoProject(name) ? 'deno' : detectPackageManager());
4649
}
4750

4851
export function getDefaultExample(cliOptions: CLIOptions): string {
@@ -139,3 +142,12 @@ export async function fetchAvailableExamples(): Promise<string[]> {
139142
return ['basic-ts', 'basic-js', 'deno-ts', 'without-cli'];
140143
}
141144
}
145+
146+
export function isDenoProject(example: string): boolean {
147+
const isOfficial = isOfficialExample(example);
148+
// if it's not an official example, we can assume it's not a Deno project
149+
// the user may use --use-deno to force a Deno project
150+
if (!isOfficial) return false;
151+
152+
return example.startsWith('deno-') || example.startsWith('with-deno-');
153+
}

0 commit comments

Comments
 (0)