Skip to content

Commit

Permalink
feat(cli): leave numbers in dirname alone
Browse files Browse the repository at this point in the history
Don't apply formatting on dirnames, only lowercase them.

Signed-off-by: Yaapa Hage <hage.yaapa@in.ibm.com>
  • Loading branch information
Yaapa Hage committed Sep 24, 2020
1 parent cf95657 commit bc2293f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/cli/lib/project-generator.js
Expand Up @@ -169,7 +169,7 @@ module.exports = class ProjectGenerator extends BaseGenerator {
// prompts if option was set to a directory that already exists
utils.validateNotExisting(this.projectInfo.outdir) !== true,
validate: utils.validateNotExisting,
default: utils.toFileName(this.projectInfo.name),
default: this.projectInfo.name && this.projectInfo.name.toLowerCase(),
},
];

Expand Down
39 changes: 39 additions & 0 deletions packages/cli/test/integration/generators/app.integration.js
Expand Up @@ -216,6 +216,45 @@ describe('app-generator with default values', () => {
});
});

/** For testing if the app names with numbers are untouched */
describe('app-generator with numbers in app name', () => {
const rootDir = path.join(__dirname, '../../../../../');
const defaultValProjPath = path.join(rootDir, 'sandbox/lb4-example');
const sandbox = path.join(rootDir, 'sandbox');
const pathToDefValApp = path.join(defaultValProjPath, 'lb4-example');
const cwd = process.cwd();
const defaultValProps = {
name: 'lb4-example',
description: 'An app to test out default values',
outdir: '',
};

before(async () => {
// lb4-example should not exist at this point
assert.equal(fs.existsSync(defaultValProjPath), false);
assert.equal(fs.existsSync(pathToDefValApp), false);
return (
helpers
.run(generator)
.inDir(defaultValProjPath)
// Mark it private to prevent accidental npm publication
.withOptions({private: true})
.withPrompts(defaultValProps)
);
});

it('scaffold a new app for lb4-example', async () => {
// lb4-example should be created at this point
assert.equal(fs.existsSync(pathToDefValApp), true);
});

after(() => {
process.chdir(sandbox);
build.clean(['node', 'run-clean', defaultValProjPath]);
process.chdir(cwd);
});
});

/** For testing the support of tilde path as the input of project path.
* Use different paths to test out the support of `~` when the test runs outside of home dir.
*/
Expand Down

0 comments on commit bc2293f

Please sign in to comment.