Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 82e8ea9

Browse files
committed
fix: reinstate Environment.home
1 parent 1965461 commit 82e8ea9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/Environment.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as pty from 'node-pty'
1111
import tmp from 'tmp'
1212
import yaml from 'js-yaml'
1313

14-
import {home} from './boot'
14+
import { home } from './boot'
1515
import spawn from './spawn'
1616
import * as nix from './nix'
1717

@@ -49,6 +49,8 @@ export class SessionParameters {
4949
stdout: stream.Writable = process.stdout
5050
}
5151

52+
let ENVIRONS_HOME = path.join(home, 'envs')
53+
5254
/**
5355
* A computational environment
5456
*/
@@ -101,11 +103,21 @@ export default class Environment {
101103
if (read) this.read()
102104
}
103105

106+
/**
107+
* Get or set the ome directory for environments
108+
*
109+
* @param value Value for home directory
110+
*/
111+
static home (value?: string): string {
112+
if (value) ENVIRONS_HOME = value
113+
return ENVIRONS_HOME
114+
}
115+
104116
/**
105117
* Path to the environment specification files
106118
*/
107119
path (): string {
108-
return path.join(home, 'envs', this.name + '.yaml')
120+
return path.join(Environment.home(), this.name + '.yaml')
109121
}
110122

111123
/**
@@ -125,7 +137,7 @@ export default class Environment {
125137
if (this.adds && this.adds.length === 0) this.adds = undefined
126138
if (this.removes && this.removes.length === 0) this.removes = undefined
127139

128-
mkdirp.sync(path.join(home, 'envs'))
140+
mkdirp.sync(Environment.home())
129141
const yml = yaml.safeDump(this, { skipInvalid: true })
130142
fs.writeFileSync(this.path(), yml)
131143
return this
@@ -168,7 +180,7 @@ export default class Environment {
168180
* List the environments on this machine
169181
*/
170182
static async envs (): Promise<Array<any>> {
171-
const names = glob.sync('*.yaml', { cwd: path.join(home, 'envs') }).map(file => file.slice(0, -5))
183+
const names = glob.sync('*.yaml', { cwd: Environment.home() }).map(file => file.slice(0, -5))
172184
const envs = []
173185
for (let name of names) {
174186
const env = new Environment(name)

src/boot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const packaged = (
2424

2525
export const home = packaged ? path.dirname(process.execPath) : path.dirname(__dirname)
2626

27-
if(packaged && !fs.existsSync(path.join(home, 'node_modules'))) {
27+
if (packaged && !fs.existsSync(path.join(home, 'node_modules'))) {
2828
tar.x({
2929
sync: true,
3030
file: path.join('/', 'snapshot', 'nixster', 'nixster.tgz'),

0 commit comments

Comments
 (0)