static.js 566 Bytes
const path = require('path');
const cp = require('child_process');

const genConfig = require('./gen-config');
const wxrc = require('./wxrc');

module.exports = ({code_path, env}) => {
  genConfig({code_path, env}).then(() => wxrc()).then(({wxpath}) => {
    const ls = cp.spawn(`${wxpath}/cli`, ['-o', path.join(__dirname, '../', code_path)]);

    ls.stdout.on('data', (data) => {
      console.log(data.toString());
    });
    ls.stderr.on('data', (data) => {
      console.log(data.toString());
    });
  }).catch(e => {
    console.error('error', e);
  });
};