Skip to content

Commit 15f95a4

Browse files
committed
Throw if template was invalid
1 parent a948d39 commit 15f95a4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/create-figma-plugin/src/create-figma-plugin-async.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { log } from '@create-figma-plugin/common'
22
import fs from 'fs-extra'
3-
import { join } from 'path'
3+
import { join, resolve } from 'path'
44

55
import { copyTemplateAsync } from './utilities/copy-template-async.js'
66
import { installDependenciesAsync } from './utilities/install-dependencies-async.js'
@@ -19,6 +19,17 @@ export async function createFigmaPluginAsync(options: {
1919
if (typeof name !== 'undefined') {
2020
await throwIfDirectoryExistsAsync(join(process.cwd(), name))
2121
}
22+
if (typeof template !== 'undefined') {
23+
const templateDirectory = resolve(
24+
__dirname,
25+
'..',
26+
'plugin-templates',
27+
template
28+
)
29+
if ((await fs.pathExists(templateDirectory)) === false) {
30+
throw new Error(`Invalid template: ${template}`)
31+
}
32+
}
2233
log.info('Scaffolding a new plugin...')
2334
const settings = useDefaults
2435
? createDefaultSettings({ name, template })

0 commit comments

Comments
 (0)