Skip to content

Commit

Permalink
change wording
Browse files Browse the repository at this point in the history
  • Loading branch information
markkaylor committed May 26, 2021
1 parent 662d438 commit 4e859c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 55,7 @@ describe('generate:template command', () => {
});

describe('handles prompt input', () => {
it('updates directory if confirmed', async () => {
it('replaces directory if confirmed', async () => {
fse.pathExists.mockReturnValue(true);
const mockInquiry = jest
.spyOn(inquirer, 'prompt')
Expand Down
12 changes: 7 additions & 5 deletions packages/strapi/lib/commands/generate-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 10,7 @@ const TEMPLATE_CONTENT = ['api', 'components', 'config/functions/bootstrap.js',

/**
*
* @param {string} templatePath Absolute path to template content directory
* @param {string} templatePath Absolute path to template directory
* @param {string} rootBase Name of the root directory
*/
async function copyContent(templatePath, rootBase) {
Expand Down Expand Up @@ -55,18 55,20 @@ async function templateConfigExists(rootPath) {
}

module.exports = async function generateTemplate(directory) {
// Allow any relative path,
// otherwise default destination is at the same level as the current directory
const dir = directory.startsWith('.') ? directory : `../${directory}`;
const rootPath = resolve(dir);

// Get path to template directory: <rootPath>/template
const templatePath = join(rootPath, 'template');

// Check if the correct template directory structure exists
// Check if the template directory exists
const exists = await fse.pathExists(templatePath);
const rootBase = basename(rootPath);

if (exists) {
// Confirm the user wants to update the existing template
// Confirm the user wants to replace the existing template
const inquiry = await inquirer.prompt({
type: 'confirm',
name: 'confirm',
Expand All @@ -78,9 80,9 @@ module.exports = async function generateTemplate(directory) {
}
}

// Create or replace the template content directory
// Create or replace root directory with <roothPath>/template
await fse.ensureDir(templatePath);
// Copy the content
// Copy content to /template
await copyContent(templatePath, rootBase);
// Create config file if it doesn't exist
const configExists = await templateConfigExists(rootPath);
Expand Down

0 comments on commit 4e859c1

Please sign in to comment.