@@ -5,11 +5,10 @@ import fs from 'fs'
55import path from 'path'
66
77import mkdirp from 'mkdirp'
8- // @ts -ignore
9- import spawn from 'await-spawn'
108import { sprintf } from 'sprintf-js'
119
1210import db from './db'
11+ import spawn from './spawn'
1312
1413/**
1514 * Create a version string that can be ordered
@@ -46,14 +45,14 @@ mkdirp.sync(profiles)
4645export async function channel ( url : string = 'https://nixos.org/channels/nixpkgs-unstable' , name : string = 'nixpkgs-unstable' ) {
4746 // Update the channel
4847 // 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 ] )
5049 // nix-channel --update [names...] : Downloads the Nix expressions of all subscribed channels (or only those included in names if specified) and
5150 // 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 ] )
5352 // 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' ] )
5554 console . log ( 'Updated channel. Current channel list:' )
56- list . stdout . pipe ( process . stdout )
55+ console . log ( list )
5756}
5857
5958/**
@@ -95,13 +94,7 @@ export async function update (channels: string | Array<string> = [], last: boole
9594 [ '--attr' , 'rPackages' ]
9695 ] ) {
9796 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 )
10598 let newPkgs
10699 try {
107100 newPkgs = JSON . parse ( json )
@@ -265,7 +258,7 @@ export async function location (env: string): Promise<string> {
265258 const profile = path . join ( profiles , env )
266259 if ( ! fs . existsSync ( profile ) ) return ''
267260 const readlink = await spawn ( 'readlink' , [ '-f' , profile ] )
268- return readlink . toString ( ) . trim ( )
261+ return readlink
269262}
270263
271264/**
0 commit comments