Build: fix build locales, make sure only read `js` files (#9879)

pull/9904/head
dongxu 2018-02-24 19:03:32 +08:00 committed by 杨奕
parent 6dbbee35e6
commit 061130e1c7
1 changed files with 18 additions and 14 deletions

View File

@ -15,21 +15,25 @@ var transform = function(filename, name, cb) {
}, cb);
};
fileList.forEach(function(file) {
var name = basename(file, '.js');
fileList
.filter(function(file) {
return /\.js$/.test(file);
})
.forEach(function(file) {
var name = basename(file, '.js');
transform(file, name, function(err, result) {
if (err) {
console.error(err);
} else {
var code = result.code;
transform(file, name, function(err, result) {
if (err) {
console.error(err);
} else {
var code = result.code;
code = code
.replace('define(\'', 'define(\'element/locale/')
.replace('global.', 'global.ELEMENT.lang = global.ELEMENT.lang || {}; \n global.ELEMENT.lang.');
save(resolve(__dirname, '../../lib/umd/locale', file)).write(code);
code = code
.replace('define(\'', 'define(\'element/locale/')
.replace('global.', 'global.ELEMENT.lang = global.ELEMENT.lang || {}; \n global.ELEMENT.lang.');
save(resolve(__dirname, '../../lib/umd/locale', file)).write(code);
console.log(file);
}
console.log(file);
}
});
});
});