Skip to content

Commit

Permalink
Removing 'del' dependency in favor of rimraf for directory deletions
Browse files Browse the repository at this point in the history
  • Loading branch information
pavolumMsft committed Nov 4, 2020
1 parent c287f9d commit 8d4592e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 310 deletions.
7 changes: 4 additions & 3 deletions Composer/packages/server/src/models/asset/assetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import path from 'path';
import { exec } from 'child_process';
import { promisify } from 'util';

import del from 'del';
import find from 'lodash/find';
import { UserIdentity, ExtensionContext, BotTemplate, FileExtensions } from '@bfc/extension';
import { mkdirs, readFile } from 'fs-extra';
import rimraf from 'rimraf';

import log from '../../logger';
import { LocalDiskStorage } from '../storage/localDiskStorage';
Expand All @@ -21,6 +21,7 @@ import { IFileStorage } from '../storage/interface';
import { BotProject } from '../bot/botProject';

const execAsync = promisify(exec);
const removeDirAndFiles = promisify(rimraf);

export class AssetManager {
public templateStorage: LocalDiskStorage;
Expand Down Expand Up @@ -90,7 +91,7 @@ export class AssetManager {
// create empty temp directory on server for holding externally hosted template src
templateSrcPath = path.resolve(__dirname, '../../../temp');
if (fs.existsSync(templateSrcPath)) {
await del(templateSrcPath);
await removeDirAndFiles(templateSrcPath);
}
await mkdirs(templateSrcPath, (err) => {
if (err) {
Expand All @@ -106,7 +107,7 @@ export class AssetManager {

if (isHostedTemplate) {
try {
await del(templateSrcPath);
await removeDirAndFiles(templateSrcPath);
} catch (err) {
throw new Error('Issue deleting temp generated file for external template assets');
}
Expand Down
Loading

0 comments on commit 8d4592e

Please sign in to comment.