Created
January 12, 2014 16:15
-
-
Save Havvy/8386654 to your computer and use it in GitHub Desktop.
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
| fez.js (*) | |
| test-src/ | |
| test-bdd.sjs (*) | |
| test/ | |
| node_modules/ | |
| fez/ | |
| fez-sweet.js/ | |
| plugin.js (*) | |
| node_modules/ | |
| sweet.js/ | |
| bluebird/ | |
| (*) Included in this gist. |
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
| #!/usr/bin/env node | |
| var fez = require('fez'); | |
| var sweetjs = require('fez-sweet.js'); | |
| exports.build = function(rule) { | |
| rule.each("test-src/*.sjs", fez.mapFile("test/%f.js"), sweetjs({'modules': ['sweet-bdd']})); | |
| }; | |
| exports.default = exports.build; | |
| fez(module); |
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
| var SweetJS = require('sweet.js'); | |
| var Promise = require('bluebird'); | |
| var inspect = require('util').inspect; | |
| module.exports = function (options) { | |
| console.log(inspect(options, {depth: null, showColors: true})); | |
| var cwd = process.cwd(); | |
| var modules = (options.modules || []).map(function (modulename) { | |
| return SweetJS.loadNodeModule(cwd, modulename); | |
| }); | |
| function sjs(promise) { | |
| return promise | |
| .then(function (input) { | |
| var src = input.toString(); | |
| console.log("SRC:", "\n", src, "\n"); | |
| console.log("Modules:", "\n", inspect(modules[0], {depth: 2, showColors: true}), "\n"); | |
| console.log("Compilation Result:"); | |
| var outfile = SweetJS.compile(src, modules).code; | |
| console.log(outfile); | |
| return outfile; | |
| }); | |
| } | |
| return function (inputs) { | |
| return Promise.all(inputs.map(function (input) { return input.asBuffer(); }).map(sjs)); | |
| } | |
| } |
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
| $ ./fez.js | |
| { modules: [ 'sweet-bdd' ] } | |
| Creating test/test-bdd.js | |
| SRC: | |
| it "x" { } | |
| Modules: | |
| { env: | |
| { __data: | |
| { 'quoteSyntax$3': [Object], | |
| 'syntax$13': [Object], | |
| '#$15': [Object], | |
| 'syntaxCase$77': [Object], | |
| 'macro$106': [Object], | |
| 'withSyntax_unzip$170': [Object], | |
| 'withSyntax$196': [Object], | |
| 'letstx$246': [Object], | |
| 'quoteSyntax$247': [Object], | |
| 'syntax$248': [Object], | |
| '#$249': [Object], | |
| 'syntaxCase$250': [Object], | |
| 'macro$251': [Object], | |
| 'withSyntax$252': [Object], | |
| 'letstx$253': [Object], | |
| 'describe$278': [Object], | |
| 'it$306': [Object], | |
| 'beforeEach$334': [Object], | |
| 'afterEach$362': [Object] } }, | |
| defscope: undefined, | |
| templateMap: | |
| { __data: | |
| { '275': [Object], | |
| '300': [Object], | |
| '303': [Object], | |
| '328': [Object], | |
| '331': [Object], | |
| '356': [Object], | |
| '359': [Object] } }, | |
| mark: undefined, | |
| exports: | |
| [ { oldExport: [Object], newParam: [Object] }, | |
| { oldExport: [Object], newParam: [Object] }, | |
| { oldExport: [Object], newParam: [Object] }, | |
| { oldExport: [Object], newParam: [Object] } ] } | |
| Compilation Result: | |
| { _bitField: 134217728, | |
| _settledValue: | |
| { [Error: Line 1: Unexpected string | |
| [... it x { } ...]] | |
| index: 3, | |
| lineNumber: 1, | |
| column: 4, | |
| description: 'Unexpected string' } } | |
| An operation has failed. Aborting. | |
| Nothing to be done. |
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
| it "x" { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
modulesisn't the second arg tosweet.compile. It should be an options object with amoduleskey: