Skip to content

Commit b08dd5b

Browse files
committed
Remove try/catch blocks
1 parent 7979119 commit b08dd5b

File tree

3 files changed

+30
-42
lines changed

3 files changed

+30
-42
lines changed

kitura-create.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ const spawn = require('child_process').spawn;
66
program
77
.parse(process.argv);
88

9-
try {
10-
let child = spawn('yo', ['swiftserver'], { stdio: 'inherit' });
11-
child.on('error', (err) => {
12-
console.error(err);
13-
});
14-
child.on('close', (code) => {
15-
process.exit(code);
16-
});
17-
} catch(err) {
9+
let child = spawn('yo', ['swiftserver'], { stdio: 'inherit' });
10+
child.on('error', (err) => {
1811
console.error(err);
19-
}
12+
});
13+
child.on('close', (code) => {
14+
process.exit(code);
15+
});

kitura-idt.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,23 @@ program
99

1010
const url = 'https://ibm.biz/kitura-idt';
1111

12-
try {
13-
// Run bash, setting stdin as a pipe
14-
let child = spawn('bash', [], { stdio: ['pipe', 'inherit', 'inherit'] });
15-
child.on('error', (err) => {
16-
console.error(err);
17-
});
18-
child.on('close', (code) => {
19-
process.exit(code);
20-
});
12+
// Run bash, setting stdin as a pipe
13+
let child = spawn('bash', [], { stdio: ['pipe', 'inherit', 'inherit'] });
14+
child.on('error', (err) => {
15+
console.error(err);
16+
});
17+
child.on('close', (code) => {
18+
process.exit(code);
19+
});
2120

22-
// Ensure that Ctrl-C also kills the child
23-
process.on('SIGINT', () => {
24-
child.kill('SIGINT');
25-
process.exit();
26-
});
21+
// Ensure that Ctrl-C also kills the child
22+
process.on('SIGINT', () => {
23+
child.kill('SIGINT');
24+
process.exit();
25+
});
2726

28-
// Download the IDT installer and pipe it to the child
29-
request
30-
.get({url, followAllRedirects: true})
31-
.on('error', (err) => { console.error(err); })
32-
.pipe(child.stdin);
33-
} catch(err) {
34-
console.error(err);
35-
}
27+
// Download the IDT installer and pipe it to the child
28+
request
29+
.get({url, followAllRedirects: true})
30+
.on('error', (err) => { console.error(err); })
31+
.pipe(child.stdin);

kitura-init.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ const spawn = require('child_process').spawn;
66
program
77
.parse(process.argv);
88

9-
try {
10-
let child = spawn('yo', ['swiftserver', '--init'], { stdio: 'inherit' });
11-
child.on('error', (err) => {
12-
console.error(err);
13-
});
14-
child.on('close', (code) => {
15-
process.exit(code);
16-
});
17-
} catch(err) {
9+
let child = spawn('yo', ['swiftserver', '--init'], { stdio: 'inherit' });
10+
child.on('error', (err) => {
1811
console.error(err);
19-
}
12+
});
13+
child.on('close', (code) => {
14+
process.exit(code);
15+
});

0 commit comments

Comments
 (0)