-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only enable typescript when detected
- Loading branch information
1 parent
d6ac11e
commit f0992b4
Showing
5 changed files
with
61 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
'use strict'; | ||
|
||
const flowEnabled = require('./flow-enabled'); | ||
const typescriptEnabled = require('./typescript-enabled'); | ||
|
||
const featuresEnabled = { | ||
flow: flowEnabled, | ||
typescript: typescriptEnabled, | ||
}; | ||
|
||
module.exports = featuresEnabled; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const typescriptEnabled = (function checkForTypescript() { | ||
const typescriptConfigFile = path.resolve(process.cwd(), 'tsconfig.json'); | ||
const typescriptExists = fs.existsSync(typescriptConfigFile); | ||
|
||
return typescriptExists; | ||
})(); | ||
|
||
module.exports = typescriptEnabled; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
const { TempSandbox } = require('temp-sandbox'); | ||
|
||
const sandbox = new TempSandbox(); | ||
const cwd = process.cwd(); | ||
|
||
beforeEach(() => { | ||
process.chdir(sandbox.dir); | ||
// Remove all files/directories inside sandbox | ||
sandbox.cleanSync(); | ||
}); | ||
|
||
afterAll(() => { | ||
// delete sandbox and sandbox instance | ||
sandbox.destroySandboxSync(); | ||
process.chdir(cwd); | ||
}); | ||
|
||
describe('detectTypescript', () => { | ||
test('detects typescript with tsconfig.json', () => { | ||
sandbox.createFileSync('tsconfig.json'); | ||
|
||
const typescriptEnabled = require('./typescript-enabled'); | ||
|
||
expect(typescriptEnabled).toEqual(true); | ||
}); | ||
|
||
test('no tsconfig.json found', () => { | ||
const typescriptEnabled = require('./typescript-enabled'); | ||
|
||
expect(typescriptEnabled).toEqual(false); | ||
}); | ||
}); |