This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: separate 'parse' and 'compile'
Close #27, close #103 BREAKING CHANGE: There won't be any wrapper code called Dredd Transactions anymore. The public interface now splits into two parts, two explicit steps, two distinct responsibilities: parse, and compile
- Loading branch information
1 parent
076dd0a
commit e915f0f
Showing
3 changed files
with
29 additions
and
246 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 |
---|---|---|
@@ -1,25 +1,5 @@ | ||
const parse = require('./parse'); | ||
const compileFromApiElements = require('./compile'); | ||
const compile = require('./compile'); | ||
|
||
|
||
function compile(apiDescription, filename, callback) { | ||
parse(apiDescription, (err, parseResult) => { | ||
// Shouldn't happen, 'parse' turns all parser crashes into annotations | ||
if (err) { callback(err); return; } | ||
|
||
// Should always set annotations and never throw, try/catch deals only | ||
// with unexpected compiler crashes | ||
let compileResult; | ||
try { | ||
const { mediaType, apiElements } = parseResult; | ||
compileResult = compileFromApiElements(mediaType, apiElements, filename); | ||
} catch (syncErr) { | ||
callback(syncErr); | ||
return; | ||
} | ||
callback(null, compileResult); | ||
}); | ||
} | ||
|
||
|
||
module.exports = { compile }; | ||
module.exports = { compile, parse }; |
This file was deleted.
Oops, something went wrong.