@@ -5,11 +5,10 @@ import fs from 'fs'
5
5
import path from 'path'
6
6
7
7
import mkdirp from 'mkdirp'
8
- // @ts -ignore
9
- import spawn from 'await-spawn'
10
8
import { sprintf } from 'sprintf-js'
11
9
12
10
import db from './db'
11
+ import spawn from './spawn'
13
12
14
13
/**
15
14
* Create a version string that can be ordered
@@ -46,14 +45,14 @@ mkdirp.sync(profiles)
46
45
export async function channel ( url : string = 'https://nixos.org/channels/nixpkgs-unstable' , name : string = 'nixpkgs-unstable' ) {
47
46
// Update the channel
48
47
// nix-channel --add url [name] : Adds a channel named name with URL url to the list of subscribed channels
49
- spawn ( 'nix-channel' , [ '--add' , url , name ] )
48
+ await spawn ( 'nix-channel' , [ '--add' , url , name ] )
50
49
// nix-channel --update [names...] : Downloads the Nix expressions of all subscribed channels (or only those included in names if specified) and
51
50
// makes them the default for nix-env operations (by symlinking them from the directory ~/.nix-defexpr).
52
- spawn ( 'nix-channel' , [ '--update' , name ] )
51
+ await spawn ( 'nix-channel' , [ '--update' , name ] )
53
52
// nix-channel --list : Prints the names and URLs of all subscribed channels on standard output.
54
- const list = spawn ( 'nix-channel' , [ '--list' ] )
53
+ const list = await spawn ( 'nix-channel' , [ '--list' ] )
55
54
console . log ( 'Updated channel. Current channel list:' )
56
- list . stdout . pipe ( process . stdout )
55
+ console . log ( list )
57
56
}
58
57
59
58
/**
@@ -95,13 +94,7 @@ export async function update (channels: string | Array<string> = [], last: boole
95
94
[ '--attr' , 'rPackages' ]
96
95
] ) {
97
96
let allArgs = args . concat ( extraArgs )
98
- let query
99
- try {
100
- query = await spawn ( 'nix-env' , allArgs )
101
- } catch ( error ) {
102
- throw new Error ( `Running "nix-env ${ allArgs . join ( ' ' ) } " failed: ${ error . stderr } ` )
103
- }
104
- let json = query . toString ( )
97
+ let json = await spawn ( 'nix-env' , allArgs )
105
98
let newPkgs
106
99
try {
107
100
newPkgs = JSON . parse ( json )
@@ -265,7 +258,7 @@ export async function location (env: string): Promise<string> {
265
258
const profile = path . join ( profiles , env )
266
259
if ( ! fs . existsSync ( profile ) ) return ''
267
260
const readlink = await spawn ( 'readlink' , [ '-f' , profile ] )
268
- return readlink . toString ( ) . trim ( )
261
+ return readlink
269
262
}
270
263
271
264
/**
0 commit comments