Skip to content

Commit

Permalink
fix: use os.homedir() to properly cope with Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Feb 24, 2021
1 parent 98acaee commit fcf93ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/agoric-cli/lib/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { promises as defaultFs } from 'fs';
import opener from 'opener';
import crypto from 'crypto';
import path from 'path';
import os from 'os';

import { openSwingStore } from '@agoric/swing-store-simple';

Expand Down Expand Up @@ -37,7 +38,7 @@ export async function getAccessToken(port, powers = {}) {
}

// Ensure we're protected with a unique accessToken for this basedir.
const sharedStateDir = path.join(process.env.HOME || '', '.agoric');
const sharedStateDir = path.join(os.homedir(), '.agoric');
await fs.mkdir(sharedStateDir, { mode: 0o700, recursive: true });

// Ensure an access token exists.
Expand Down
3 changes: 2 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/access-token.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs';
import crypto from 'crypto';
import os from 'os';
import path from 'path';

import { openSwingStore } from '@agoric/swing-store-simple';
Expand Down Expand Up @@ -27,7 +28,7 @@ export function generateAccessToken({

export async function getAccessToken(port) {
// Ensure we're protected with a unique accessToken for this basedir.
const sharedStateDir = path.join(process.env.HOME || '', '.agoric');
const sharedStateDir = path.join(os.homedir(), '.agoric');
await fs.promises.mkdir(sharedStateDir, { mode: 0o700, recursive: true });

// Ensure an access token exists.
Expand Down
4 changes: 3 additions & 1 deletion packages/cosmic-swingset/lib/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
} from '@agoric/swingset-vat/src/devices/mailbox';

import { assert, details as X } from '@agoric/assert';
import os from 'os';

import { launch } from './launch-chain';
import makeBlockManager from './block-manager';
import { getMeterProvider } from './kernel-stats';
Expand Down Expand Up @@ -103,7 +105,7 @@ export default async function main(progname, args, { path, env, agcc }) {

// We try to find the actual cosmos state directory (default=~/.ag-chain-cosmos), which
// is better than scribbling into the current directory.
const cosmosHome = getFlagValue('home', `${env.HOME}/.ag-chain-cosmos`);
const cosmosHome = getFlagValue('home', `${os.homedir()}/.ag-chain-cosmos`);
const stateDBDir = `${cosmosHome}/data/ag-cosmos-chain-state`;

// console.log('Have AG_COSMOS', agcc);
Expand Down

0 comments on commit fcf93ad

Please sign in to comment.