forked from numworks/setup-emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (28 loc) · 1.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const core = require('@actions/core')
const exec = require('@actions/exec')
const tc = require('@actions/tool-cache')
const fs = require('fs')
const os = require('os')
const path = require('path')
async function run() {
try {
const sdk = core.getInput('sdk')
await exec.exec('git', ['clone', 'https://github.com/emscripten-core/emsdk.git'])
const emSdk = await tc.cacheDir('emsdk', 'emscripten', 'latest');
core.exportVariable('EMSDK', emSdk)
core.addPath(emSdk)
await exec.exec('emsdk', ['install', sdk])
await exec.exec('emsdk', ['activate', sdk])
const emConfPath = path.join(os.homedir(), '.emscripten')
core.exportVariable('EM_CONFIG', emConfPath)
const emConf = fs.readFileSync(emConfPath).toString()
const emRoot = emConf.match(/EMSCRIPTEN_ROOT = '(.*)'/)[1]
core.addPath(emRoot)
const emNode = emConf.match(/NODE_JS = '(.*)'/)[1]
core.exportVariable('EMSDK_NODE', emNode)
core.addPath(path.dirname(emNode))
} catch (error) {
core.setFailed(error.message);
}
}
run()