@@ -1,3 +1,8 @@
3+ sendPermanentNotification,
4+} = require("notifications");
1function readStream(readableStream) {
6function readStream(readableStream) {
2 return new Promise((resolve, _reject) => {
7 return new Promise((resolve, _reject) => {
3 const reader = readableStream.getReader();
8 const reader = readableStream.getReader();
@@ -48,4 +53,88 @@ function traceRaw(x) {
56+async function call(path, args) {
57+ const env = await getEnv()
58+ const process = new Process(path, {...args, ...{env}});
59+ const promise = new Promise((resolve, reject) => {
60+ process.onDidExit((exitCode) => {
61+ console.log(exitCode)
63+ readStream(process.stdout).then((x) => {
67+ readStream(process.stderr).then((x) => {
78+function parseEnvs(x) {
80+ for (line of x.split("\n")) {
81+ const res = line.match(/(.*?)=(.*)/)
87+ console.log(JSON.stringify(env))
94+async function createEnv() {
95+ const generator = nova.workspace.config.get("env-generator")
97+ const [prog, ...args] = generator.split(/\s+/)
98+ sendNotification("Generating environment", "Executing " + generator + ".")
99+ const process = new Process(prog, {
102+ cwd: nova.workspace.path
104+ const promise = new Promise((resolve, reject) => {
105+ process.onDidExit((exitCode) => {
106+ console.log(exitCode)
107+ if (exitCode == 0) {
108+ readStream(process.stdout).then((x) => {
112+ readStream(process.stderr).then((x) => {
120+ const envStr = await promise
121+ .catch((err) => sendPermanentNotification("Generating environment failed", err))
122+ envCache = parseEnvs(envStr)
126+async function getEnv() {
127+ console.log(JSON.stringify(envCache))
135+function hasCustomEnv() {
136+ return (nova.workspace.config.get("env-generator") !== null)
51−module.exports = { readStream, getStorage, getFileName, trace, traceRaw };
139+module.exports = { readStream, getStorage, getFileName, trace, traceRaw, call, createEnv, hasCustomEnv, getEnv };