UNPKG

825 BJavaScriptView Raw
1/**
2 * gulp-espower - A gulp plugin to apply espower to target files.
3 *
4 * https://github.com/twada/gulp-espower
5 *
6 * Copyright (c) 2013-2014 Takuto Wada
7 * Licensed under the MIT license.
8 * https://raw.github.com/twada/gulp-espower/master/LICENSE-MIT
9 */
10var es = require('event-stream'),
11 espowerSourceToSource = require('espower-source');
12
13module.exports = function (opt) {
14 'use strict';
15
16 function instrument(file, cb) {
17 if (file.isNull()) {
18 cb(null, file); // pass along
19 } else if (file.isStream()) {
20 cb(new Error('gulp-espower: Streaming not supported'));
21 } else {
22 file.contents = new Buffer(espowerSourceToSource(file.contents.toString('utf8'), file.path, opt));
23 cb(null, file);
24 }
25 }
26
27 return es.map(instrument);
28};