Skip to content

Commit d81669e

Browse files
committed
fix: replace "~" by home dir
1 parent 66009dc commit d81669e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

apps/generator-cli/src/app/services/version-manager.service.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { LOGGER } from '../constants';
77
import * as chalk from 'chalk';
88
import { ConfigService } from './config.service';
99
import { resolve } from 'path';
10+
import * as os from 'os';
1011
import { TestingModule } from '@nestjs/testing/testing-module';
1112

1213
jest.mock('fs-extra');
@@ -534,6 +535,9 @@ describe('VersionManagerService', () => {
534535
it.each([
535536
['/c/w/d/custom/dir', './custom/dir'],
536537
['/custom/dir', '/custom/dir'],
538+
['/custom/dir', '/custom/dir/'],
539+
[`${os.homedir()}/oa`, '~/oa/'],
540+
[`${os.homedir()}/oa`, '~/oa'],
537541
])('returns %s for %s', async (expected, cfgValue) => {
538542
getStorageDir.mockReturnValue(cfgValue)
539543
await compile()

apps/generator-cli/src/app/services/version-manager.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {replace} from 'lodash';
44
import {Observable} from 'rxjs';
55
import * as fs from 'fs-extra';
66
import * as path from 'path';
7+
import * as os from 'os';
78
import * as Stream from 'stream';
89
import * as chalk from 'chalk';
910
import * as compare from 'compare-versions'
@@ -31,7 +32,7 @@ export class VersionManagerService {
3132

3233
public readonly storage = this.customStorageDir ? path.resolve(
3334
this.configService.cwd,
34-
this.customStorageDir,
35+
this.customStorageDir.replace('~', os.homedir()),
3536
) : path.resolve(__dirname, './versions')
3637

3738
constructor(

0 commit comments

Comments
 (0)