This repository has been archived by the owner on May 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add build scripts to programmatically create files ace editor can con…
…sume
- Loading branch information
1 parent
fdf36c5
commit dc2750b
Showing
3 changed files
with
68 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ acceptance/ | |
.compared | ||
node_modules/ | ||
lib/gherkin/dialects.json | ||
dist/ |
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,63 @@ | ||
var gulp = require('gulp'); | ||
var wrap = require('gulp-wrap-amd'); | ||
var through = require('through2'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
|
||
function replaceAll(str, find, replace) { | ||
return str.split(find).join(replace); | ||
} | ||
|
||
gulp.task('wrap:gherkin', function () { | ||
gulp.src('./lib/**/*.js') | ||
.pipe(through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
cb(null, file); | ||
return; | ||
} | ||
|
||
var fileName = path.basename(file.path); | ||
var newFileContents = replaceAll(file.contents.toString(), "require('tea-error')", "require('./tea/error')"); | ||
|
||
if (fileName === 'token_matcher.js') { | ||
// token_matcher.js requires a json file. To make the file browser compatible, we need to paste the | ||
// contents of the json file into the js file | ||
return fs.readFile(path.join(__dirname, 'lib/gherkin/dialects.json'), 'utf8', function (err, data) { | ||
if (err) throw err; | ||
file.contents = new Buffer(replaceAll(newFileContents, "require('./dialects.json')", data.trim())); | ||
cb(null, file); | ||
}); | ||
} | ||
|
||
file.contents = new Buffer(newFileContents); | ||
cb(null, file); | ||
})) | ||
.pipe(wrap({ | ||
exports: 'module.exports' | ||
})) | ||
.pipe(gulp.dest('./dist/')) | ||
}); | ||
|
||
gulp.task('wrap:node_modules', function () { | ||
gulp.src([ | ||
'./node_modules/tea-error/lib/error.js', | ||
'./node_modules/tea-error/node_modules/tea-extend/lib/extend.js' | ||
]) | ||
.pipe(through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
cb(null, file); | ||
return; | ||
} | ||
|
||
var newFileContents = replaceAll(file.contents.toString(), "require('tea-extend')", "require('./extend')"); | ||
file.contents = new Buffer(newFileContents); | ||
|
||
cb(null, file); | ||
})) | ||
.pipe(wrap({ | ||
exports: 'module.exports' | ||
})) | ||
.pipe(gulp.dest('./dist/gherkin/tea')) | ||
}); | ||
|
||
gulp.task('default', ['wrap:gherkin', 'wrap:node_modules']); |
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