ant-design/scripts/prenpm.js

21 lines
774 B
JavaScript
Raw Normal View History

2015-07-15 12:07:11 +08:00
var fs = require('fs');
var cwd = process.cwd();
var path = require('path');
2015-07-21 18:06:42 +08:00
var pkg = require('../package');
2015-11-03 15:46:56 +08:00
var originalIndex = fs.readFileSync(path.join(cwd, 'lib/index.js'), 'utf-8');
2015-07-15 12:07:11 +08:00
var newIndex = originalIndex
.replace(/\/components\//g, '/')
2015-11-03 15:46:56 +08:00
.replace(/require\(\'\.\/package.json\'\)/g, "require('./package')")
2015-11-25 18:19:45 +08:00
.replace("require('./style/index.less')", "require('./index.css')");
2015-07-15 12:07:11 +08:00
fs.writeFileSync(path.join(cwd, 'lib/index.js'), newIndex, 'utf-8');
2015-11-03 15:46:56 +08:00
fs.writeFileSync(
path.join(cwd, 'lib/package.js'),
"module.exports = " + JSON.stringify(require('../package.json')) + ";",
'utf-8'
);
2015-10-22 19:09:23 +08:00
var antdCss = path.join(cwd, 'dist/index.css');
fs.createReadStream(antdCss)
.pipe(fs.createWriteStream(path.join(cwd, 'lib/index.css')));
2015-07-21 18:06:42 +08:00
console.log('prenpm done');