add version (#4751)

* add version

* add version to dist
This commit is contained in:
yiminghe 2017-02-08 14:53:18 +08:00 committed by ddcat1115
parent 3789e0cbbb
commit dbae84c83d

View File

@ -4,13 +4,43 @@
'use strict';
// Build a entry less file to dist/antd.less
var fs = require('fs');
var path = require('path');
const fs = require('fs');
const path = require('path');
const packageInfo = require('../package.json');
if (fs.existsSync(path.join(__dirname, '../dist'))) {
fs.writeFileSync(path.join(process.cwd(), 'lib', 'version.js'), `
module.exports = '${packageInfo.version}';
`);
const antdV = `
(function(root) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports.version = '${packageInfo.version}';
else
root["antd"].version = '${packageInfo.version}';
})(this);
`;
const antdPath = path.join(process.cwd(), 'dist', 'antd.js');
const antdMinPath = path.join(process.cwd(), 'dist', 'antd.min.js');
if (fs.existsSync(antdPath)) {
const content = fs.readFileSync(antdPath, 'utf-8');
const minContent = fs.readFileSync(antdMinPath, 'utf-8');
fs.writeFileSync(antdPath, `
${content}
${antdV}
`);
fs.writeFileSync(antdMinPath, `
${minContent}
${antdV}
`);
}
if(fs.existsSync(path.join(__dirname,'../dist'))) {
console.log('Building a entry less file to dist/antd.less');
var componentsPath = path.join(process.cwd(), 'components');
var componentsLessContent = '';
const componentsPath = path.join(process.cwd(), 'components');
let componentsLessContent = '';
// Build components in one file: lib/style/components.less
fs.readdir(componentsPath, function (err, files) {