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

Commit dee4eaf

Browse files
nokomebeneboy
authored andcommitted
fix: make the profiles directory only when necessary
1 parent 44387f3 commit dee4eaf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/nix.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ try {
3636
// Currently we're putting generate Nix profiles in the /nix directory.
3737
// This is somewhat arbitrary.
3838
const profiles = path.join('/', 'nix', 'profiles')
39-
mkdirp.sync(profiles)
4039

4140
/**
4241
* Add a channel
@@ -249,7 +248,7 @@ export async function search (term: string, type: string = '', limit: number = 1
249248
*/
250249
export function location (env: string): string {
251250
const profile = path.join(profiles, env)
252-
if (!fs.existsSync(profile)) throw new Error(`Profile for environment "${env}" not exist at "${profile}"`)
251+
if (!fs.existsSync(profile)) throw new Error(`Profile for environment "${env}" does not exist at "${profile}"`)
253252
const location = fs.realpathSync(profile)
254253
if (location.length === 0) throw new Error(`Could not resolve location of environment "${env}" from the profile "${profile}"`)
255254
return location
@@ -296,6 +295,8 @@ export async function install (env: string, pkgs: Array<string>, clean: boolean
296295
} else {
297296
profile = path.join(profiles, env)
298297
}
298+
// Ensure the profiles directory is present
299+
mkdirp.sync(path.dirname(profile))
299300
args = args.concat(
300301
'--profile', profile,
301302
'--attr', channels[channel].map((pkg: any) => pkg.attr)

0 commit comments

Comments
 (0)