-
Notifications
You must be signed in to change notification settings - Fork 16
Add compile
option
#12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
32584f3
init
szmarczak e9afefe
Fix test macros
szmarczak 6a11b00
Customize projectDir in provider macro
szmarczak f6e2961
Editorconfig for package.json
szmarczak 3c497ea
Test compile() error
szmarczak dfa8611
Update snapshots
szmarczak 56ab684
Fixes
szmarczak d2437c1
Frendlier errors
szmarczak cf9afe0
Simplify an if
szmarczak 9beea39
Fix linting
szmarczak 2bde6bc
.gitignore
szmarczak 51faaf9
Delete test/fixtures/typescript/compiled directory
szmarczak 591d720
Delete test/broken-fixtures/typescript/compiled directory
szmarczak 4990d27
Update Node.js on GitHub Actions
szmarczak d2e3f00
Inline validators
novemberborn beab39d
Use 'tsc' config value, update readme
novemberborn 1ed976e
Merge branch 'main' into precompile
novemberborn 553e632
execa is now a regular dependency
novemberborn c41f838
Fix validation
novemberborn 3e265fa
Fix compile option validation
novemberborn 1c979e2
Add TypeScript dev dependency
novemberborn 68a2947
Increase test timeout
novemberborn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -10,3 +10,6 @@ insert_final_newline = true | |
[*.yml] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[package.json] | ||
indent_style = space |
This file contains hidden or 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,2 +1,4 @@ | ||
/coverage | ||
/node_modules | ||
/test/fixtures/typescript/compiled | ||
/test/broken-fixtures/typescript/compiled |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
const path = require('path'); | ||
const pkg = require('../package.json'); | ||
const makeProvider = require('..'); | ||
|
||
const createProviderMacro = (identifier, avaVersion, projectDir = __dirname) => { | ||
return (t, run) => run(t, makeProvider({ | ||
negotiateProtocol(identifiers, {version}) { | ||
t.true(identifiers.includes(identifier)); | ||
t.is(version, pkg.version); | ||
return { | ||
ava: {avaVersion}, | ||
identifier, | ||
normalizeGlobPatterns: patterns => patterns, | ||
async findFiles({patterns}) { | ||
return patterns.map(file => path.join(projectDir, file)); | ||
}, | ||
projectDir | ||
}; | ||
} | ||
})); | ||
}; | ||
|
||
module.exports = createProviderMacro; |
This file contains hidden or 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 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "typescript/compiled" | ||
}, | ||
"include": [ | ||
"typescript" | ||
] | ||
} |
This file contains hidden or 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 @@ | ||
a |
This file contains hidden or 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,61 @@ | ||
const path = require('path'); | ||
const test = require('ava'); | ||
const del = require('del'); | ||
const execa = require('execa'); | ||
const createProviderMacro = require('./_with-provider'); | ||
|
||
const withProvider = createProviderMacro('ava-3.2', '3.2.0', path.join(__dirname, 'fixtures')); | ||
const withAltProvider = createProviderMacro('ava-3.2', '3.2.0', path.join(__dirname, 'broken-fixtures')); | ||
|
||
test.before('deleting compiled files', async t => { | ||
t.log(await del('test/fixtures/typescript/compiled')); | ||
t.log(await del('test/broken-fixtures/typescript/compiled')); | ||
}); | ||
|
||
const compile = async provider => { | ||
return { | ||
state: await provider.main({ | ||
config: { | ||
rewritePaths: { | ||
'ts/': 'typescript/', | ||
'compiled/': 'typescript/compiled/' | ||
}, | ||
compile: 'tsc' | ||
} | ||
}).compile() | ||
}; | ||
}; | ||
|
||
test('worker(): load rewritten paths files', withProvider, async (t, provider) => { | ||
const {state} = await compile(provider); | ||
const {stdout, stderr} = await execa.node( | ||
path.join(__dirname, 'fixtures/install-and-load'), | ||
[JSON.stringify(state), path.join(__dirname, 'fixtures/ts', 'file.ts')], | ||
{cwd: path.join(__dirname, 'fixtures')} | ||
); | ||
if (stderr.length > 0) { | ||
t.log(stderr); | ||
} | ||
|
||
t.snapshot(stdout); | ||
}); | ||
|
||
test('worker(): runs compiled files', withProvider, async (t, provider) => { | ||
const {state} = await compile(provider); | ||
const {stdout, stderr} = await execa.node( | ||
path.join(__dirname, 'fixtures/install-and-load'), | ||
[JSON.stringify(state), path.join(__dirname, 'fixtures/compiled', 'index.ts')], | ||
{cwd: path.join(__dirname, 'fixtures')} | ||
); | ||
if (stderr.length > 0) { | ||
t.log(stderr); | ||
} | ||
|
||
t.snapshot(stdout); | ||
}); | ||
|
||
test('compile() error', withAltProvider, async (t, provider) => { | ||
const {message} = await t.throwsAsync(compile(provider)); | ||
|
||
t.snapshot(message); | ||
}); |
This file contains hidden or 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 hidden or 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 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "typescript/compiled" | ||
}, | ||
"include": [ | ||
"typescript" | ||
] | ||
} |
File renamed without changes.
This file contains hidden or 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 @@ | ||
console.log('logged in fixtures/typescript/index.ts'); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.