From 061130e1c76e0d960ba90978ca7f777cecb0a5e8 Mon Sep 17 00:00:00 2001 From: dongxu Date: Sat, 24 Feb 2018 19:03:32 +0800 Subject: [PATCH] Build: fix build locales, make sure only read `js` files (#9879) --- build/bin/build-locale.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/build/bin/build-locale.js b/build/bin/build-locale.js index 211e426ce..ad66ae318 100644 --- a/build/bin/build-locale.js +++ b/build/bin/build-locale.js @@ -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); + } + }); }); -});