-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (34 loc) · 1.03 KB
/
index.js
File metadata and controls
45 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2016 - present UTN-LIS
'use strict';
var path = require('path'),
gulpUtil = require('gulp-util'),
through = require('through2'),
puma = require('pumascript');
module.exports = function (fileName) {
if (!fileName) {
throw new gulpUtil.PluginError('gulp-puma', gulpUtil.colors.green('fileName') + ' required');
}
var firstFile,
content = '';
return through.obj(function (file, enc, callback) {
if (!firstFile) {
firstFile = file;
}
content += file.contents.toString();
callback();
}, function (callback) {
if (!firstFile) {
callback();
return;
}
var result = puma.evalPuma(content);
gulpUtil.log('PumaScript run successful');
this.push(new gulpUtil.File({
cwd: firstFile.cwd,
base: firstFile.base,
path: path.join(firstFile.base, 'result.js'),
contents: new Buffer(result.output)
}));
callback();
});
};