Skip to content

Commit

Permalink
fix: add overwrite: true to overwrite on existing file
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Mar 10, 2021
1 parent ee56b7b commit 23b0f6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions apps/generator-cli/src/app/services/version-manager.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Test } from '@nestjs/testing';
import { Version, VersionManagerService } from './version-manager.service';
import { HttpService } from '@nestjs/common';
import { of } from 'rxjs';
import { mocked } from 'ts-jest/utils';
import { LOGGER } from '../constants';
import {Test} from '@nestjs/testing';
import {Version, VersionManagerService} from './version-manager.service';
import {HttpService} from '@nestjs/common';
import {of} from 'rxjs';
import {mocked} from 'ts-jest/utils';
import {LOGGER} from '../constants';
import * as chalk from 'chalk';
import { ConfigService } from './config.service';
import { resolve } from 'path';
import {ConfigService} from './config.service';
import {resolve} from 'path';
import * as os from 'os';
import { TestingModule } from '@nestjs/testing/testing-module';
import {TestingModule} from '@nestjs/testing/testing-module';

jest.mock('fs-extra');
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down Expand Up @@ -450,7 +450,7 @@ describe('VersionManagerService', () => {
});

it('moves the file to the target location', () => {
expect(fs.moveSync).toHaveBeenNthCalledWith(1, '/tmp/generator-cli-abcDEF/4.2.0', `${fixture.storage}/4.2.0.jar`);
expect(fs.moveSync).toHaveBeenNthCalledWith(1, '/tmp/generator-cli-abcDEF/4.2.0', `${fixture.storage}/4.2.0.jar`, {overwrite: true});
});

it('receives the data piped', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class VersionManagerService {
const file = fs.createWriteStream(temporaryFilePath);
res.data.pipe(file);
file.on('finish', content => {
fs.moveSync(temporaryFilePath, filePath);
fs.moveSync(temporaryFilePath, filePath, {overwrite: true});
resolve(content);
});
})
Expand Down

0 comments on commit 23b0f6f

Please sign in to comment.