Skip to content

Commit

Permalink
fix: secrets edit creates unique temp directory for editing the secret
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
tegefaulkes committed Jun 5, 2024
1 parent 330a6c4 commit 0deae29
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/secrets/CommandEdit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type PolykeyClient from 'polykey/dist/PolykeyClient';
import fs from 'fs';
import path from 'path';
import * as errors from '../errors';
import CommandPolykey from '../CommandPolykey';
import * as binUtils from '../utils';
Expand Down Expand Up @@ -62,10 +64,10 @@ class CommandEdit extends CommandPolykey {
meta,
);
const secretContent = response.secretContent;
// Linux
const tmpDir = `${os.tmpdir}/pksecret`;
await this.fs.promises.mkdir(tmpDir);
const tmpFile = `${tmpDir}/pkSecretFile`;
const tmpDir = await fs.promises.mkdtemp(
path.join(os.tmpdir(), 'polykey-'),
);
const tmpFile = path.join(tmpDir, 'pksecret');
await this.fs.promises.writeFile(tmpFile, secretContent);
execSync(`$EDITOR \"${tmpFile}\"`, { stdio: 'inherit' });
let content: Buffer;
Expand Down

0 comments on commit 0deae29

Please sign in to comment.