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