Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(copyFile): replace copyFileSync to shell.cp #585

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cmd/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
);
}

async function handler(args: Arguments<any>) {

Check warning on line 177 in src/cmd/build/index.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Unexpected any. Specify a different type
const userOutputFolder = resolve(args.output);
const tmpInputFolder = resolve(args.output, TMP_INPUT_FOLDER);
const tmpOutputFolder = resolve(args.output, TMP_OUTPUT_FOLDER);
Expand All @@ -186,7 +186,7 @@
input: tmpInputFolder,
output: tmpOutputFolder,
});
Includers.init([OpenapiIncluder as any]);

Check warning on line 189 in src/cmd/build/index.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Unexpected any. Specify a different type

const {
output: outputFolderPath,
Expand Down Expand Up @@ -303,7 +303,6 @@
// Create temporary input/output folders
shell.rm('-rf', args.input, args.output);
shell.mkdir(args.input, args.output);
shell.chmod('-R', 'u+w', args.input);

copyFiles(
args.rootInput,
Expand All @@ -315,4 +314,6 @@
ignore: ['node_modules/**', '*/node_modules/**'],
}),
);

shell.chmod('-R', 'u+w', args.input);
}
4 changes: 2 additions & 2 deletions src/services/tocs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {dirname, extname, join, normalize, parse, relative, resolve, sep} from 'path';
import {copyFileSync, existsSync, readFileSync, writeFileSync} from 'fs';
import {existsSync, readFileSync, writeFileSync} from 'fs';
import {dump, load} from 'js-yaml';
import shell from 'shelljs';
import walkSync from 'walk-sync';
Expand Down Expand Up @@ -205,7 +205,7 @@ function _copyTocDir(tocPath: string, destDir: string) {

writeFileSync(to, updatedFileContent);
} else {
copyFileSync(from, to);
shell.cp(from, to);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/steps/processPages.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {DocInnerProps} from '@diplodoc/client';
import {basename, dirname, extname, join, relative, resolve} from 'path';
import shell from 'shelljs';
import {copyFileSync, readFileSync, writeFileSync} from 'fs';
import {readFileSync, writeFileSync} from 'fs';
import {bold} from 'chalk';
import {dump, load} from 'js-yaml';
import {asyncify, mapLimit} from 'async';
Expand Down Expand Up @@ -312,7 +312,7 @@ function copyFileWithoutChanges(
const from = resolvedPathToFile;
const to = resolve(outputDir, filename);

copyFileSync(from, to);
shell.cp(from, to);
}

async function processingFileToMd(path: PathData, metaDataOptions: MetaDataOptions): Promise<void> {
Expand Down
17 changes: 11 additions & 6 deletions src/utils/file.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import {dirname, resolve} from 'path';
import shell from 'shelljs';
import {copyFileSync} from 'fs';
import {logger} from './logger';

export function copyFiles(
inputFolderPath: string,
outputFolderPath: string,
files: string[],
): void {
for (const pathToAsset of files) {
const outputDir: string = resolve(outputFolderPath, dirname(pathToAsset));
const dirs = new Set<string>();

files.forEach((pathToAsset) => {
const outputDir = resolve(outputFolderPath, dirname(pathToAsset));
const from = resolve(inputFolderPath, pathToAsset);
const to = resolve(outputFolderPath, pathToAsset);

shell.mkdir('-p', outputDir);
copyFileSync(from, to);
if (!dirs.has(outputDir)) {
dirs.add(outputDir);
shell.mkdir('-p', outputDir);
}

shell.cp(from, to);

logger.copy(pathToAsset);
}
});
}
Loading