Skip to content

Commit

Permalink
fix: remove unexpected tsconfig.json from JavaScript creation (#83)
Browse files Browse the repository at this point in the history
* fix: remove unexpected tsconfig.json from JavaScript creation

* test: add ut
  • Loading branch information
leftstick authored and sorrycc committed Sep 30, 2019
1 parent d04ba3d commit 873f30d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/generators/ant-design-pro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class AntDesignProGenerator extends BasicGenerator {
});

log('[JS] Clean up...');
const removeTsFiles = globList(['**/*.d.ts'], envOptions);
const removeTsFiles = globList(['tsconfig.json', '**/*.d.ts'], envOptions);
removeTsFiles.forEach(filePath => {
const targetPath = path.resolve(projectPath, filePath);
fs.removeSync(targetPath);
Expand Down
24 changes: 24 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,28 @@ describe('test umi-create', () => {
assert.equal(response.stdout, expectStdout.join('\n'));
assert.equal(response.code, 0);
});

it('tsconfig.json should be removed if JavaScript is picked', async () => {
let temp = fs.mkdtempSync(path.join(os.tmpdir(), `umi-create`));
if (os.platform() === 'darwin') {
temp = path.join('/private', temp);
}
const Coffee = coffee.Coffee;
const fixtures = path.join(__dirname, 'fixtures');
const response = await new Coffee({
method: 'fork',
cmd: path.join(__dirname, '../cli.js'),
opt: { cwd: temp },
})
.beforeScript(path.join(fixtures, 'mock_cnpmjs.js'))
.waitForPrompt()
.write('\n')
.waitForPrompt()
.writeKey('DOWN', 'ENTER')
.end();

assert.equal(response.code, 0);
assert.ok(fs.existsSync(path.join(temp, 'jsconfig.json')));
assert.ok(!fs.existsSync(path.join(temp, 'tsconfig.json')));
});
});

0 comments on commit 873f30d

Please sign in to comment.