Skip to content

Commit adeaada

Browse files
committed
Ensure deno is installed
1 parent d9350d1 commit adeaada

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

packages/deno/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@
2424
"rollup-plugin-dts": "^6.1.0"
2525
},
2626
"scripts": {
27-
"prebuild": "deno types > lib.deno.d.ts",
27+
"install:deno": "node ./scripts/install-deno.mjs && deno types > lib.deno.d.ts",
28+
"prebuild": "yarn install:deno",
2829
"build": "rollup -c rollup.config.js",
2930
"postbuild": "deno check build/index.js",
3031
"build:dev": "yarn build",
3132
"build:watch": "run-p build:transpile:watch build:types:watch",
3233
"build:dev:watch": "yarn build:watch",
3334
"circularDepCheck": "madge --circular src/index.ts",
3435
"clean": "rimraf build coverage",
36+
"prefix": "yarn install:deno",
3537
"fix": "run-s fix:eslint fix:prettier",
3638
"fix:eslint": "eslint . --format stylish --fix",
3739
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
40+
"prelint": "yarn install:deno",
3841
"lint": "run-s lint:prettier lint:eslint",
3942
"lint:eslint": "eslint . --format stylish",
4043
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\""
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { execSync } from 'child_process';
2+
3+
async function download(url) {
4+
try {
5+
return await fetch(url).then(res => res.text());
6+
} catch (e) {
7+
console.error('Failed to download', url, e);
8+
process.exit(1);
9+
}
10+
}
11+
12+
try {
13+
// Ensure we're using the latest Deno version
14+
execSync('deno upgrade', { stdio: 'inherit' });
15+
} catch (_) {
16+
console.error('Deno is not installed. Installing...');
17+
if (process.platform === 'win32') {
18+
// TODO
19+
console.error('Please install Deno manually: https://docs.deno.com/runtime/manual/getting_started/installation');
20+
process.exit(1);
21+
} else {
22+
const script = await download('https://deno.land/x/install/install.sh');
23+
24+
try {
25+
execSync(script, { stdio: 'inherit' });
26+
} catch (e) {
27+
console.error('Failed to install Deno', e);
28+
process.exit(1);
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)