-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
3,035 additions
and
718 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
const foo = (arg): void => {} |
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,6 @@ | ||
interface User { | ||
age?: number | ||
} | ||
const myUser: User = {} | ||
|
||
console.log(myUser.age.toString()) |
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,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs" | ||
} | ||
} |
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,51 @@ | ||
import simpleGit from 'simple-git/promise' | ||
import tmp from 'tmp-promise' | ||
import execa from 'execa' | ||
import { join } from 'path' | ||
import { copy, outputFile } from 'fs-extra' | ||
|
||
const runTsStrictifyInPath = async (path: string): Promise<string> => { | ||
const cwd = process.cwd() | ||
const tsStrictify = join(cwd, 'dist/bin.js') | ||
|
||
process.chdir(path) | ||
return execa('node', [tsStrictify]) | ||
.then((response) => response.stdout) | ||
.catch((error) => error.stdout) | ||
.finally(() => process.chdir(cwd)) | ||
} | ||
|
||
test('files are detected correctly', async () => { | ||
jest.setTimeout(20000) | ||
const { path } = await tmp.dir() | ||
const git = simpleGit(path) | ||
|
||
await git | ||
.init() | ||
.then(() => git.addConfig('user.name', 'Some One')) | ||
.then(() => git.addConfig('user.email', 'some@one.com')) | ||
.then(() => copy(join(__dirname, 'repository'), path)) | ||
.then(() => git.add('./*')) | ||
.then(() => git.commit('First commit')) | ||
.then(() => runTsStrictifyInPath(path)) | ||
.then((stdout) => expect(stdout).toMatch(/Found 0 changed file/)) | ||
|
||
await git | ||
.checkoutLocalBranch('feature') | ||
.then(() => outputFile(join(path, 'foo.ts'), 'const foo = (arg): void => {}')) | ||
.then(() => runTsStrictifyInPath(path)) | ||
.then((stdout) => { | ||
expect(stdout).toMatch(/Found 1 changed file/) | ||
expect(stdout).toMatch(/error TS7006: Parameter 'arg' implicitly has an 'any' type/) | ||
}) | ||
|
||
await git | ||
.add('./*') | ||
.then(() => runTsStrictifyInPath(path)) | ||
.then((stdout) => expect(stdout).toMatch(/Found 1 changed file/)) | ||
|
||
await git | ||
.commit('Second commit') | ||
.then(() => runTsStrictifyInPath(path)) | ||
.then((stdout) => expect(stdout).toMatch(/Found 1 changed file/)) | ||
}) |
Oops, something went wrong.