-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): implement the first features for release 💫
- Loading branch information
Kent C. Dodds
committed
Jan 19, 2017
1 parent
849a309
commit 3e66f8f
Showing
24 changed files
with
757 additions
and
86 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 |
---|---|---|
|
@@ -6,5 +6,11 @@ | |
} | ||
}], | ||
"stage-2" | ||
], | ||
"plugins": [ | ||
["transform-runtime", { | ||
"polyfill": false, | ||
"regenerator": true | ||
}] | ||
] | ||
} |
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules | |
.nyc_output | ||
coverage | ||
dist | ||
cli-test/fixtures |
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,8 @@ | ||
module.exports = { | ||
readFile: jest.fn((filePath, encoding, callback) => { | ||
callback(null, `console.log('this is a mock thing for file: ${filePath}')`) | ||
}), | ||
writeFile: jest.fn((filePath, contents, callback) => { | ||
callback(null) | ||
}), | ||
} |
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,5 @@ | ||
module.exports = jest.fn(async function mockGetStdin() { | ||
return module.exports.stdin | ||
}) | ||
|
||
module.exports.stdin = '' |
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,39 @@ | ||
module.exports = jest.fn(function mockGlob(globString, options, callback) { | ||
/* eslint complexity:0 */ | ||
if (globString.includes('1')) { | ||
callback(null, [ | ||
fredProject('index.js'), | ||
fredProject('start.js'), | ||
fredProject('stop/index.js'), | ||
fredProject('stop/log.js'), | ||
]) | ||
} else if (globString.includes('2')) { | ||
callback(null, [ | ||
fredProject('index.js'), | ||
fredProject('start.js'), | ||
fredProject('continue/index.js'), | ||
fredProject('continue/forever.js'), | ||
]) | ||
} else if (globString.includes('node_modules')) { | ||
callback(null, [ | ||
fredProject('foo/node_modules/stuff1.js'), | ||
fredProject('foo/node_modules/stuff2.js'), | ||
fredProject('foo/node_modules/stuff3.js'), | ||
]) | ||
} else if (globString.includes('files-with-syntax-errors')) { | ||
callback(null, [ | ||
fredProject('syntax-error1.js'), | ||
fredProject('syntax-error2.js'), | ||
]) | ||
} else if (globString.includes('no-match')) { | ||
callback(null, []) | ||
} else if (globString.includes('throw-error')) { | ||
callback(new Error('something weird happened')) | ||
} else { | ||
throw new Error(`Your test globString: "${globString}" doesn't have associated mock data.`) | ||
} | ||
}) | ||
|
||
function fredProject(path) { | ||
return `/Users/fredFlintstone/Developer/top-secret/footless-carriage/${path}` | ||
} |
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,11 @@ | ||
// This is the mock that will be used in tests | ||
// Jest sets this up automatically http://facebook.github.io/jest/docs/manual-mocks.html | ||
// so we just return some spies here and assert that we're calling prettier-eslint APIs correctly | ||
const format = jest.fn(({text, filePath = ''}) => { | ||
if (text === 'MOCK_SYNTAX_ERROR' || filePath.includes('syntax-error')) { | ||
throw new Error('Mock error for a syntax error') | ||
} | ||
return `MOCK_OUTPUT for ${filePath || 'stdin'}` | ||
}) | ||
|
||
export default format |
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 @@ | ||
import baz , { stuff } from | ||
'fdjakfdlfw-baz' | ||
|
||
export { | ||
bazzy | ||
|
||
} | ||
|
||
|
||
function bazzy(something) { | ||
return baz( stuff( something ) ); | ||
};;;;;;;;;;;;;;;;;;;;; | ||
|
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,10 @@ | ||
export | ||
default foo | ||
|
||
function foo ( | ||
thing | ||
) { | ||
return ( | ||
thing) | ||
} | ||
|
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,12 @@ | ||
{ | ||
"testPathDirs": [ | ||
"<rootDir>/cli-test/tests" | ||
], | ||
"testEnvironment": "jest-environment-node", | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/", | ||
"/helpers/", | ||
"/fixtures/" | ||
], | ||
"testRegex": "^.*.js$" | ||
} |
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,20 @@ | ||
exports[`file contents: prettier-eslint cli-test/fixtures/example1.js cli-test/fixtures/example2.js 1`] = ` | ||
Object { | ||
"example1Result": "const {example1} = baz.bar | ||
", | ||
"example2Result": "function example2(thing) { | ||
return thing | ||
} | ||
", | ||
} | ||
`; | ||
|
||
exports[`stdout: --version 1`] = ` | ||
"0.0.0-semantically-released | ||
" | ||
`; | ||
|
||
exports[`stdout: prettier-eslint cli-test/fixtures/example1.js cli-test/fixtures/example2.js 1`] = ` | ||
"success formatting 2 files with prettier-eslint | ||
" | ||
`; |
Oops, something went wrong.