Skip to content

Commit 1a7cc94

Browse files
committed
fix
1 parent fc01be7 commit 1a7cc94

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

packages/create-rslib/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1313
async function getTemplateName({ template }: Argv) {
1414
if (typeof template === 'string') {
1515
const pair = template.split('-');
16-
const language = pair[1] ?? 'js';
17-
const type = pair[0];
18-
return `${type}-${language}`;
16+
const lang = pair[pair.length - 1];
17+
if (lang && ['js', 'ts'].includes(lang)) {
18+
return template;
19+
}
20+
// default to js
21+
return `${template}-js`;
1922
}
2023

2124
const type = checkCancel<string>(
@@ -42,7 +45,7 @@ async function getTemplateName({ template }: Argv) {
4245
}
4346

4447
function mapESLintTemplate(templateName: string) {
45-
const language = templateName.split('-')[1];
48+
const language = templateName.split('-').pop();
4649
return `vanilla-${language}` as ESLintTemplateName;
4750
}
4851

packages/create-rslib/test/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ test('should create node-esm-ts project as expected', async () => {
2020
});
2121

2222
test('should allow to create project in sub dir', async () => {
23-
createAndValidate(__dirname, 'example', {
23+
createAndValidate(__dirname, 'node-esm-js', {
2424
name: 'test-temp-dir/rslib-project',
2525
});
2626
});
2727

2828
test('should allow to create project in relative dir', async () => {
29-
createAndValidate(__dirname, 'example', {
29+
createAndValidate(__dirname, 'node-esm-js', {
3030
name: './test-temp-relative-dir',
3131
});
3232
});
3333

3434
test('should create project with eslint as expected', async () => {
35-
const { dir, pkgJson, clean } = createAndValidate(__dirname, 'example', {
35+
const { dir, pkgJson, clean } = createAndValidate(__dirname, 'node-esm-js', {
3636
name: 'test-temp-eslint',
3737
tools: ['eslint'],
3838
clean: false,
@@ -43,7 +43,7 @@ test('should create project with eslint as expected', async () => {
4343
});
4444

4545
test('should create project with prettier as expected', async () => {
46-
const { dir, pkgJson, clean } = createAndValidate(__dirname, 'example', {
46+
const { dir, pkgJson, clean } = createAndValidate(__dirname, 'node-esm-js', {
4747
name: 'test-temp-prettier',
4848
tools: ['prettier'],
4949
clean: false,
@@ -54,7 +54,7 @@ test('should create project with prettier as expected', async () => {
5454
});
5555

5656
test('should create project with eslint and prettier as expected', async () => {
57-
const { dir, pkgJson, clean } = createAndValidate(__dirname, 'example', {
57+
const { dir, pkgJson, clean } = createAndValidate(__dirname, 'node-esm-js', {
5858
name: 'test-temp-eslint-prettier',
5959
tools: ['eslint', 'prettier'],
6060
clean: false,
@@ -67,7 +67,7 @@ test('should create project with eslint and prettier as expected', async () => {
6767
});
6868

6969
test('should create project with biome as expected', async () => {
70-
const { dir, pkgJson, clean } = createAndValidate(__dirname, 'example', {
70+
const { dir, pkgJson, clean } = createAndValidate(__dirname, 'node-esm-js', {
7171
name: 'test-temp-eslint',
7272
tools: ['biome'],
7373
clean: false,

0 commit comments

Comments
 (0)