Skip to content

Commit

Permalink
fix: backport scripts/link-cli.js
Browse files Browse the repository at this point in the history
Fixes #661

We avoid Promises to allow this script to run under older
system versions of node.
  • Loading branch information
michaelfig committed Mar 6, 2020
1 parent d5df315 commit 2974075
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"check-dependencies": "node ./scripts/check-mismatched-dependencies.js",
"prettier": "yarn workspaces run prettier",
"lerna": "lerna",
"link-cli": "node ./scripts/link-cli.js",
"link-cli": "node ./scripts/link-cli.cjs",
"lint-fix": "yarn workspaces run lint-fix",
"lint-check": "yarn workspaces run lint-check",
"test": "yarn workspaces run test",
Expand Down
23 changes: 23 additions & 0 deletions scripts/link-cli.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /usr/bin/env node

const fs = require('fs');
const path = require('path');

try {
const script = process.argv[2] || '/usr/local/bin/agoric';
const cli = path.resolve(__dirname, '../packages/agoric-cli/bin/agoric');
const content = `\
#! /bin/sh
# AUTOMATICALLY GENERATED by ${process.argv[1]}
# Always execute the checked-out Agoric CLI with the --sdk flag.
exec ${cli} --sdk \${1+"\$@"}
`;
console.log(`creating ${script}`);
fs.writeFileSync(script, content);
fs.chmodSync(script, '0755');
} catch (e) {
console.error(err);
process.exit(1);
}

process.exit(0);
21 changes: 0 additions & 21 deletions scripts/link-cli.js

This file was deleted.

0 comments on commit 2974075

Please sign in to comment.