@@ -209,7 +209,7 @@ export default class Environment {
209
209
envs . push ( Object . assign ( { } , env , {
210
210
path : env . path ( ) ,
211
211
built : await nix . built ( name ) ,
212
- location : await nix . location ( name )
212
+ location : nix . location ( name )
213
213
} ) )
214
214
}
215
215
return envs
@@ -225,7 +225,7 @@ export default class Environment {
225
225
226
226
const desc : any = Object . assign ( { } , this , {
227
227
path : this . path ( ) ,
228
- location : await nix . location ( this . name ) ,
228
+ location : nix . location ( this . name ) ,
229
229
packages : await nix . packages ( this . name )
230
230
} )
231
231
@@ -346,7 +346,7 @@ export default class Environment {
346
346
347
347
// The Dockerfile does essentially the same as the `docker run` command
348
348
// generated above in `dockerRun`...
349
- const location = await nix . location ( this . name )
349
+ const location = nix . location ( this . name )
350
350
const dockerfile = `
351
351
FROM alpine
352
352
ENV PATH ${ location } /bin:${ location } /sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@@ -380,8 +380,8 @@ export default class Environment {
380
380
*
381
381
* @param pure Should the shell that this command is executed in be 'pure'?
382
382
*/
383
- async vars ( pure : boolean = false ) : Promise < { [ key : string ] : string } > {
384
- const location = await nix . location ( this . name )
383
+ async vars ( pure : boolean = false ) : Promise < { [ key : string ] : string } > {
384
+ const location = nix . location ( this . name )
385
385
386
386
let PATH = `${ location } /bin:${ location } /sbin`
387
387
if ( ! pure ) PATH += ':' + process . env . PATH
@@ -411,9 +411,16 @@ export default class Environment {
411
411
} )
412
412
}
413
413
414
+ /**
415
+ * Get an array suitable for passing to `spawn` to execute a docker command with default args for nixster
416
+ *
417
+ * @param dockerCommand The Docker command to execute
418
+ * @param sessionParameters SessionParameters to use for limiting Docker's resource usage
419
+ * @param daemonize Should the Docker command be run with the '-d' flag?
420
+ */
414
421
private async getDockerShellArgs ( dockerCommand : string , sessionParameters : SessionParameters , daemonize : boolean = false ) : Promise < Array < string > > {
415
422
const { command, cpuShares, memoryLimit } = sessionParameters
416
- const nixLocation = await nix . location ( this . name )
423
+ const nixLocation = nix . location ( this . name )
417
424
const shellArgs = [
418
425
dockerCommand , '--interactive' , '--tty' , '--rm' ,
419
426
// Prepend the environment path to the PATH variable
@@ -552,7 +559,12 @@ export default class Environment {
552
559
if ( platform === Platform . UNIX && command ) shellProcess . write ( command + '\r' )
553
560
}
554
561
555
- private async checkContainerRunning ( containerId : string ) {
562
+ /**
563
+ * Determine if a Docker container is running using 'docker ps'
564
+ *
565
+ * @param containerId The ID of the container, can either be the long or truncated version.
566
+ */
567
+ private async checkContainerRunning ( containerId : string ) : Promise < boolean > {
556
568
const containerRegex = new RegExp ( / ^ [ ^ _ \W ] { 12 } $ / )
557
569
if ( containerRegex . exec ( containerId ) === null ) {
558
570
throw new Error ( `'${ containerId } ' is not a valid docker container ID.` )
@@ -591,7 +603,7 @@ export default class Environment {
591
603
592
604
// The Dockerfile does essentially the same as the `docker run` command
593
605
// generated above in `dockerRun`...
594
- const location = await nix . location ( this . name )
606
+ const location = nix . location ( this . name )
595
607
const dockerfile = `
596
608
FROM alpine
597
609
ENV PATH ${ location } /bin:${ location } /sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
0 commit comments