UNPKG

kmc

Version:
67 lines (60 loc) 1.63 kB
/** * * @author: daxingplay<daxingplay@gmail.com> * @time: 13-3-12 11:43 * @description: */ var kmc = require('../index'), fs = require('fs'), path = require('path'), utils = require('../lib/utils'), srcPath = path.resolve(__dirname, '../test/src/'), distPath = path.resolve(__dirname, './dist'); var result; // build with only one package. kmc.config({ packages: [{ name: 'package1', path: srcPath, charset: 'gbk' }], silent: true, charset: 'gbk' }); result = kmc.analyze(path.resolve(srcPath, 'package1/build-with-kissy.js')); console.log(result); // build and generate dep file for KISSY 1.3 auto combo. var file1 = path.resolve(srcPath, 'package1/build-with-kissy.js'), file1output = path.resolve(distPath, 'package1/build-with-kissy.js'); kmc.config({ packages: [{ name: 'package1', path: srcPath, charset: 'gbk' }], silent: true, charset: 'gbk' }); result = kmc.build(file1, file1output, 'gbk', 'dep.js'); console.log(result); // build with two packages and generate dep file. kmc.config({ packages: [{ name: 'package1', path: srcPath, charset: 'gbk' }, { name: 'package2', path: srcPath, charset: 'utf-8' }], silent: true, charset: 'gbk' }); result = kmc.analyze(path.resolve(srcPath, 'package1/two-package-simple.js')); kmc.build(path.resolve(srcPath, 'package1/two-package-simple.js'), path.resolve(distPath, 'test.js'), 'gbk', 'dep.js'); console.log(result); // clean output. if(fs.existsSync(distPath)){ utils.rmdirsSync(distPath); }