Skip to content

Commit 2c1ff12

Browse files
author
Gitlab-CI
committed
fix(cmds): fix copy and intl
1 parent 28a97c3 commit 2c1ff12

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/cli/cmds/copy.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22
const async = require('async');
33
const path = require('path');
44
const fs = require('fs');
5+
6+
const { spawn: spawnDefault, exec: execDefault } = require('child_process');
7+
8+
const exec = (command, cb) => {
9+
execDefault(command, {
10+
maxBuffer: 1024 * 1024,
11+
}, cb);
12+
};
13+
const spawn = (command, cb) => {
14+
const split = command.split(' ');
15+
const program = split[0];
16+
const args = split.slice(1);
17+
const child = spawnDefault(program, args || []);
18+
const outputList = [];
19+
child.stdout.setEncoding('utf8');
20+
child.stderr.setEncoding('utf8');
21+
child.stdout.on('data', (data) => outputList.push(data) && console.log(data.replace(/\n$/, '')));
22+
child.stderr.on('data', (data) => outputList.push(data) && console.log(data.replace(/\n$/, '')));
23+
child.on('close', (code) => code === 1 ? cb(new Error(`child process exited with code ${code}`, [outputList.join('')])) : cb(null, [outputList.join('')]));
24+
};
25+
526
exports.command = 'copy';
627
exports.desc = 'Copy template documentation from `internal/templates/docs` to `docs`.';
728
exports.builder = (yargs) => yargs

src/cli/cmds/intl.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22
const path = require('path');
33
const fs = require('fs');
44
const async = require('async');
5+
const { spawn: spawnDefault, exec: execDefault } = require('child_process');
6+
7+
const exec = (command, cb) => {
8+
execDefault(command, {
9+
maxBuffer: 1024 * 1024,
10+
}, cb);
11+
};
12+
const spawn = (command, cb) => {
13+
const split = command.split(' ');
14+
const program = split[0];
15+
const args = split.slice(1);
16+
const child = spawnDefault(program, args || []);
17+
const outputList = [];
18+
child.stdout.setEncoding('utf8');
19+
child.stderr.setEncoding('utf8');
20+
child.stdout.on('data', (data) => outputList.push(data) && console.log(data.replace(/\n$/, '')));
21+
child.stderr.on('data', (data) => outputList.push(data) && console.log(data.replace(/\n$/, '')));
22+
child.on('close', (code) => code === 1 ? cb(new Error(`child process exited with code ${code}`, [outputList.join('')])) : cb(null, [outputList.join('')]));
23+
};
524

625
const emptyLink = (pkg, lang, isPrivate) => isPrivate ? `*empty* ([edit now](${pkg.bugs.url.split('/issues')[0]}/edit/dev/translate/${lang}.json))` : `*empty*`;
726
require('shelljs/global');

0 commit comments

Comments
 (0)