Skip to content

Commit

Permalink
fix: replace "~" by home dir
Browse files Browse the repository at this point in the history
  • Loading branch information
kay-schecker committed Nov 5, 2020
1 parent 66009dc commit d81669e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { LOGGER } from '../constants';
import * as chalk from 'chalk';
import { ConfigService } from './config.service';
import { resolve } from 'path';
import * as os from 'os';
import { TestingModule } from '@nestjs/testing/testing-module';

jest.mock('fs-extra');
Expand Down Expand Up @@ -534,6 +535,9 @@ describe('VersionManagerService', () => {
it.each([
['/c/w/d/custom/dir', './custom/dir'],
['/custom/dir', '/custom/dir'],
['/custom/dir', '/custom/dir/'],
[`${os.homedir()}/oa`, '~/oa/'],
[`${os.homedir()}/oa`, '~/oa'],
])('returns %s for %s', async (expected, cfgValue) => {
getStorageDir.mockReturnValue(cfgValue)
await compile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {replace} from 'lodash';
import {Observable} from 'rxjs';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as os from 'os';
import * as Stream from 'stream';
import * as chalk from 'chalk';
import * as compare from 'compare-versions'
Expand Down Expand Up @@ -31,7 +32,7 @@ export class VersionManagerService {

public readonly storage = this.customStorageDir ? path.resolve(
this.configService.cwd,
this.customStorageDir,
this.customStorageDir.replace('~', os.homedir()),
) : path.resolve(__dirname, './versions')

constructor(
Expand Down

0 comments on commit d81669e

Please sign in to comment.