Skip to content
This repository was archived by the owner on May 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 23 additions & 32 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,22 @@ export class Compiler {
}

await utility.mkdirs(path.dirname(outputPath), undefined);
const { stderr } = await utility
.execute(
compiler,
[
...flags,
'-c',
'-o',
options.cwd
? path.relative(options.cwd, outputPath)
: outputPath,
options.cwd ? path.relative(options.cwd, srcPath) : srcPath,
],
{ cwd: options.cwd, shell: true }
)
.catch(err => {
if (err.err.code === 'ENOENT') {
throw new Error(
`Not found '${compiler}. Have you install it?'`
);
}
return { stderr: err.stderr as string | Buffer };
});
const { stderr, err } = await utility.execute(
compiler,
[
...flags,
'-c',
'-o',
options.cwd
? path.relative(options.cwd, outputPath)
: outputPath,
options.cwd ? path.relative(options.cwd, srcPath) : srcPath,
],
{ cwd: options.cwd, shell: true }
);

if (err) throw err;

return message.parseClangMessage(stderr.toString());
}

Expand Down Expand Up @@ -188,16 +182,13 @@ export class Compiler {
);
}
await utility.mkdirs(path.dirname(outputPath), undefined);
const { stderr } = await utility
.execute(options.ld, flags, { cwd: options.cwd, shell: true })
.catch(err => {
if (err.err.code === 'ENOENT') {
throw new Error(
`Not found '${options.ld}. Have you install it?'`
);
}
return { stderr: err.stderr as string | Buffer };
});
const { stderr, err } = await utility.execute(options.ld, flags, {
cwd: options.cwd,
shell: true,
});

if (err) throw err;

return message.parseClangMessage(stderr.toString());
}

Expand Down
9 changes: 5 additions & 4 deletions src/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ export async function getDependencies(
flags: string[],
cwd?: string
) {
const { stdout } = await execute(
const { stdout, err } = await execute(
compiler,
[...flags, '-MM', cwd ? path.relative(cwd, absPath) : absPath],
{ cwd, shell: true }
).catch(err => {
throw err.err;
});
);

if (err) throw err;

const dependencies = stdout
.toString()
.trim()
Expand Down