2019-05-24 13:24:04 +00:00
|
|
|
const fs = require('fs-extra');
|
|
|
|
const path = require('path');
|
2019-05-29 07:11:07 +00:00
|
|
|
const { execSync } = require('child_process');
|
2019-05-24 13:24:04 +00:00
|
|
|
const vueCliServicePath = path.resolve(__dirname, 'node_modules/@vue/cli-service/bin/vue-cli-service');
|
|
|
|
|
|
|
|
fs.readdirSync(path.resolve(__dirname, './src/components/')).forEach(folder => {
|
|
|
|
fs.readdirSync(path.resolve(__dirname, './src/components/' + folder)).forEach(file => {
|
2019-05-29 07:11:07 +00:00
|
|
|
let filename = file.split(/(.vue)$|(.js)$/)[0].toLowerCase();
|
|
|
|
if (/\.vue$/.test(file)) {
|
2019-05-30 09:57:33 +00:00
|
|
|
console.log('Building ' + green(filename));
|
2019-05-25 16:03:57 +00:00
|
|
|
|
2019-05-24 13:24:04 +00:00
|
|
|
execSync(
|
|
|
|
`node ${vueCliServicePath} build src/components/${folder}/${file} --target lib --name ${filename} --dest components/${folder} --no-clean `
|
|
|
|
)
|
|
|
|
}
|
2019-05-29 07:11:07 +00:00
|
|
|
else if (/\.js$/.test(file)) {
|
|
|
|
console.log('Building ' + blue(filename));
|
|
|
|
|
|
|
|
execSync(
|
|
|
|
`node ${vueCliServicePath} build src/components/${folder}/${file} --target lib --name ${filename} --dest components/${folder} --no-clean `
|
|
|
|
)
|
|
|
|
|
|
|
|
execSync(
|
|
|
|
`babel --no-babelrc src/components/${folder}/${file} --out-file components/${folder}/${file} --presets=es2015,stage-2 `
|
|
|
|
)
|
|
|
|
}
|
2019-05-24 13:24:04 +00:00
|
|
|
});
|
2019-05-29 07:11:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function blue (str) {
|
2019-05-30 09:57:33 +00:00
|
|
|
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m';
|
|
|
|
}
|
|
|
|
|
|
|
|
function green (str) {
|
|
|
|
return '\x1b[1m\x1b[32m' + str + '\x1b[39m\x1b[22m';
|
2019-05-29 07:11:07 +00:00
|
|
|
}
|