Skip to content

Commit

Permalink
fix(intl): extract command was missing importof spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitlab-CI committed Nov 17, 2018
1 parent ed23655 commit c0340d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cli/cmds/intl_cmds/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const shell = require('shelljs');
const { transform } = require('babel-core');
const { animateProgress, addCheckMark } = require('kopaxgroup-cli-helpers');
require('shelljs/global');
const { spawn } = require('../../utils');

// Glob to match all js files except test files
const FILES_TO_PARSE = 'src/**/!(*.test).js';
Expand Down
18 changes: 18 additions & 0 deletions src/cli/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { spawn: spawnDefault } = require('child_process');

const spawn = (command, cb) => {
const split = command.split(' ');
const program = split[0];
const args = split.slice(1);
const child = spawnDefault(program, args || []);
const outputList = [];
child.stdout.setEncoding('utf8');
child.stderr.setEncoding('utf8');
child.stdout.on('data', (data) => outputList.push(data) && console.log(data.replace(/\n$/, '')));
child.stderr.on('data', (data) => outputList.push(data) && console.log(data.replace(/\n$/, '')));
child.on('close', (code) => code === 1 ? cb(new Error(`child process exited with code ${code}`, [outputList.join('')])) : cb(null, [outputList.join('')]));
};

module.exports = {
spawn,
};

0 comments on commit c0340d1

Please # to comment.