mirror of
https://github.com/strapi/strapi.git
synced 2025-12-06 03:52:38 +00:00
only ask about generating a ts Plugin in a javascript project
This commit is contained in:
parent
adce607d00
commit
c49d681b18
@ -27,6 +27,14 @@ ${separator}
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = (plop) => {
|
module.exports = (plop) => {
|
||||||
|
const currentDir = process.cwd();
|
||||||
|
const typescriptPrompt = tsUtils.isUsingTypeScriptSync(currentDir) ? [] : [{
|
||||||
|
type: 'list',
|
||||||
|
name: 'isTypescript',
|
||||||
|
message: 'Choose your preferred language',
|
||||||
|
choices: ['Javascript', 'Typescript'],
|
||||||
|
default: 'Javascript',
|
||||||
|
}];
|
||||||
// Plugin generator
|
// Plugin generator
|
||||||
plop.setGenerator('plugin', {
|
plop.setGenerator('plugin', {
|
||||||
description: 'Generate a basic plugin',
|
description: 'Generate a basic plugin',
|
||||||
@ -36,17 +44,10 @@ module.exports = (plop) => {
|
|||||||
name: 'pluginName',
|
name: 'pluginName',
|
||||||
message: 'Plugin name',
|
message: 'Plugin name',
|
||||||
},
|
},
|
||||||
{
|
...typescriptPrompt
|
||||||
type: 'list',
|
|
||||||
name: 'isTypescript',
|
|
||||||
message: 'Choose your preferred language',
|
|
||||||
choices: ['Javascript', 'Typescript'],
|
|
||||||
default: 'Javascript',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
actions(answers) {
|
actions(answers) {
|
||||||
const currentDir = process.cwd();
|
const isTypescript = answers?.isTypescript === 'Typescript';
|
||||||
const isTypescript = answers.isTypescript === 'Typescript';
|
|
||||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) || isTypescript ? 'ts' : 'js';
|
const language = tsUtils.isUsingTypeScriptSync(currentDir) || isTypescript ? 'ts' : 'js';
|
||||||
|
|
||||||
// TODO: Adds tsconfig & build command for TS plugins?
|
// TODO: Adds tsconfig & build command for TS plugins?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user