forked from mrblueblue/gettext-loader
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
36 lines (27 loc) · 829 Bytes
/
Copy pathgulpfile.babel.js
File metadata and controls
36 lines (27 loc) · 829 Bytes
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
'use strict';
import {compose, map, remove} from 'ramda';
import fs from 'fs';
import gulp from 'gulp';
gulp.task('utils', () => {
fs.readdir('src/utils', (err, data) => {
function removeIndexFile(files){
let indexIndex = files.indexOf('index.js');
return remove(indexIndex, 1, files);
}
function removeExtension(str){
let periodIndex = str.split('').indexOf('.');
return str.substring(0, periodIndex);
}
function buildExportStatement(file){
return `export ${file} from './${file}';\n`;
}
const files = compose(
map(buildExportStatement),
map(removeExtension),
removeIndexFile
)(data);
console.log('creating /utils/index.js ...');
console.log(files.join(''));
fs.writeFileSync('src/utils/index.js', files.join(''));
});
});