Skip to content
Snippets Groups Projects
Commit b1989038 authored by Shachar Itzhaky's avatar Shachar Itzhaky
Browse files

[bugfix] Forgot to await `cas`.

parent d9247f6e
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ function cat(fn: string) {
async function cas(fn: string, expectedValue: string, whenNeq: () => void | Promise<void>) {
if (cat(fn) === expectedValue) return true; /* fast lane */
let dir = path.dirname(fn),
lopts = {lockfileName: fn + '.lock', retries: cas_retries};
lopts = {lockfilePath: fn + '.lock', retries: cas_retries};
await lockfile.lock(dir, lopts);
try {
if (cat(fn) === expectedValue) return true;
......@@ -62,4 +62,4 @@ function existsDir(p) {
catch (e) { return false; }
}
export { cat, cas, dirstamp, ln_sf, existsExec, existsDir }
\ No newline at end of file
export { cat, cas, dirstamp, ln_sf, existsExec, existsDir }
......@@ -29,7 +29,7 @@ class Phase {
_exec(prog, args, stdio='inherit') {
if (SDK_FLAGS.includes('verbose')) {
console.log(`[${ME}-sdk] `, prog, args.join(' '));
log(`[${ME}-sdk] ${prog} ${args.join(' ')}`);
}
return child_process.execFileSync(prog, args, {stdio});
}
......@@ -65,7 +65,7 @@ class DockerTool extends Phase {
async run(prog, args) {
const cfg = await sdk.setup(this.basedir, false);
cfg.include = this.incdir;
this.copyToVolume(cfg);
await this.copyToVolume(cfg);
this.runInContainer(prog, args, cfg);
}
......@@ -101,9 +101,11 @@ class DockerTool extends Phase {
([k, v]) => v ? ['-e', `${k}=${v}`] : []));
}
copyToVolume(cfg) {
async copyToVolume(cfg) {
let {name, mnt} = this.dockerVolume;
cas(path.join(cfg.coqlib, '_volume'), 'jscoq-sdk', () => {
await cas(path.join(cfg.coqlib, '_volume'), 'jscoq-sdk', () => {
if (SDK_FLAGS.includes('verbose'))
log(`[${ME}-sdk] creating volume ${name}`);
this._exec('docker', ['volume', 'rm', '-f', name], ['ignore', 'ignore', 'inherit']);
this._exec('docker', ['volume', 'create', name], ['ignore', 'ignore', 'inherit']);
this.runInContainer('sudo', ['cp', '-rf', cfg.coqlib, mnt], cfg);
......@@ -120,6 +122,11 @@ class DockerTool extends Phase {
}
}
/** logs to stderr to avoid cluttering output, esp. for coqdep */
function log(msg) {
process.stderr.write(msg + '\n');
}
async function main(prog, args) {
var Phase = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment