@react-native-oh/react-native-harmony-cli 0.0.36 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/assetResolver.js +74 -43
- package/dist/autolinking/Autolinking.js +183 -179
- package/dist/codegen/core/CodegenError.js +23 -3
- package/dist/codegen/core/EventUtils.js +3 -3
- package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
- package/dist/codegen/core/UberSchema.js +96 -57
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +42 -28
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
- package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
- package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
- package/dist/codegen/generators/UberGeneratorV1.js +24 -18
- package/dist/codegen/generators/UberGeneratorV2.js +36 -28
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
- package/dist/codegen/templates/BasePackageHTemplate.js +21 -109
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -53
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
- package/dist/codegen/templates/IndexTSTemplate.js +17 -37
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -108
- package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
- package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
- package/dist/commands/bundle-harmony.js +138 -53
- package/dist/commands/codegen-harmony.js +175 -104
- package/dist/commands/codegen-lib-harmony.js +116 -76
- package/dist/commands/create-metro-host-constants.js +47 -18
- package/dist/commands/init.js +961 -537
- package/dist/commands/link-harmony.js +71 -33
- package/dist/commands/pack-harmony.js +108 -47
- package/dist/commands/run-harmony.js +520 -352
- package/dist/commands/unpack-harmony.js +198 -105
- package/dist/commands/verify-package-harmony.js +108 -54
- package/dist/core/AbsolutePath.js +47 -31
- package/dist/core/CodegenConfig.js +22 -24
- package/dist/core/DescriptiveError.js +37 -18
- package/dist/core/FileSystem.js +18 -14
- package/dist/core/OHPackageJSON5.js +23 -17
- package/dist/core/PackageJSON.js +42 -26
- package/dist/core/ProjectDependenciesManager.js +96 -46
- package/dist/core/ValidationError.js +22 -2
- package/dist/core/fs.js +6 -9
- package/dist/index.js +1 -1
- package/dist/io/CliExecutor.js +98 -46
- package/dist/io/Logger.js +46 -40
- package/dist/io/RealFS.js +88 -35
- package/dist/io/TarGz.js +8 -11
- package/dist/io/__fixtures__.js +141 -79
- package/dist/io/fsUtils.js +12 -13
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
- package/dist/package-verifier/verify-package.js +132 -55
- package/dist/simulator/LaunchSimulator.js +395 -0
- package/dist/simulator/index.js +23 -0
- package/jest.config.js +12 -12
- package/package.json +78 -70
- package/react-native.config.js +17 -17
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
- package/.prettierrc +0 -6
- package/src/assetResolver.ts +0 -134
- package/src/autolinking/Autolinking.test.ts +0 -483
- package/src/autolinking/Autolinking.ts +0 -382
- package/src/autolinking/index.ts +0 -8
- package/src/codegen/core/CodeGenerator.ts +0 -16
- package/src/codegen/core/CodegenError.ts +0 -10
- package/src/codegen/core/EventUtils.ts +0 -23
- package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
- package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
- package/src/codegen/core/UberSchema.ts +0 -152
- package/src/codegen/core/index.ts +0 -12
- package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -120
- package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
- package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
- package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
- package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
- package/src/codegen/generators/UberGeneratorV1.ts +0 -75
- package/src/codegen/generators/UberGeneratorV2.ts +0 -114
- package/src/codegen/generators/index.ts +0 -15
- package/src/codegen/index.ts +0 -9
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
- package/src/codegen/templates/BasePackageHTemplate.ts +0 -147
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
- package/src/codegen/templates/IndexTSTemplate.ts +0 -62
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -138
- package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
- package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
- package/src/codegen/templates/index.ts +0 -16
- package/src/commands/bundle-harmony.ts +0 -134
- package/src/commands/codegen-harmony.ts +0 -297
- package/src/commands/codegen-lib-harmony.ts +0 -389
- package/src/commands/create-metro-host-constants.ts +0 -55
- package/src/commands/index.ts +0 -16
- package/src/commands/init.ts +0 -755
- package/src/commands/link-harmony.ts +0 -102
- package/src/commands/pack-harmony.ts +0 -128
- package/src/commands/run-harmony.ts +0 -478
- package/src/commands/types.ts +0 -21
- package/src/commands/unpack-harmony.ts +0 -238
- package/src/commands/verify-package-harmony.ts +0 -113
- package/src/core/AbsolutePath.ts +0 -66
- package/src/core/CodegenConfig.ts +0 -67
- package/src/core/DescriptiveError.ts +0 -68
- package/src/core/FileSystem.ts +0 -57
- package/src/core/OHPackageJSON5.ts +0 -30
- package/src/core/PackageJSON.ts +0 -104
- package/src/core/ProjectDependenciesManager.ts +0 -103
- package/src/core/ValidationError.ts +0 -8
- package/src/core/ValueObject.ts +0 -9
- package/src/core/fs.ts +0 -38
- package/src/core/index.ts +0 -17
- package/src/index.ts +0 -33
- package/src/io/CliExecutor.ts +0 -69
- package/src/io/Logger.ts +0 -112
- package/src/io/RealFS.ts +0 -62
- package/src/io/TarGz.ts +0 -33
- package/src/io/__fixtures__.ts +0 -139
- package/src/io/fsUtils.ts +0 -44
- package/src/io/index.ts +0 -11
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
- package/src/package-verifier/checks/index.ts +0 -11
- package/src/package-verifier/index.ts +0 -9
- package/src/package-verifier/types.ts +0 -19
- package/src/package-verifier/verify-package.ts +0 -123
package/package.json
CHANGED
|
@@ -1,70 +1,78 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@react-native-oh/react-native-harmony-cli",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"publishConfig": {
|
|
6
|
-
"registry": "https://registry.npmjs.org/",
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "tsc --outDir dist -p tsconfig.build.json",
|
|
11
|
-
"prepack": "npm run build",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"test
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"@
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-oh/react-native-harmony-cli",
|
|
3
|
+
"version": "0.0.40",
|
|
4
|
+
"description": "",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"registry": "https://registry.npmjs.org/",
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc --outDir dist -p tsconfig.build.json",
|
|
11
|
+
"prepack": "npm run build && npm run _recreate-hvigor-plugin",
|
|
12
|
+
"_recreate-hvigor-plugin": "cd ../react-native-harmony-hvigor-plugin && npm i && npm run deploy && cd ../react-native-harmony-cli",
|
|
13
|
+
"verify": "tsc --noEmit && npm run test",
|
|
14
|
+
"test": "npm run build && jest",
|
|
15
|
+
"test:codegen": "jest ./src/codegen/.* && npm run build && jest tests/codegen.*",
|
|
16
|
+
"rn": "npm run build && react-native",
|
|
17
|
+
"prepublishOnly": "npm run verify"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"rnoh-cli": "dist/commands/init.js"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [],
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"metro": "*"
|
|
27
|
+
},
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"files": [
|
|
30
|
+
"./*.js",
|
|
31
|
+
"./*.json",
|
|
32
|
+
"./dist/*",
|
|
33
|
+
"./harmony/*",
|
|
34
|
+
"./README.md"
|
|
35
|
+
],
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@react-native-community/cli": "^15.0.0",
|
|
38
|
+
"@react-native-community/cli-types": "^11.3.0",
|
|
39
|
+
"@types/adm-zip": "^0.5.5",
|
|
40
|
+
"@types/fs-extra": "^11.0.1",
|
|
41
|
+
"@types/jest": "^29.5.1",
|
|
42
|
+
"@types/jszip": "^3.4.1",
|
|
43
|
+
"@types/mustache": "^4.2.5",
|
|
44
|
+
"@types/tar": "^6.1.5",
|
|
45
|
+
"@types/tmp": "^0.2.3",
|
|
46
|
+
"directory-tree": "^3.5.1",
|
|
47
|
+
"execa": "npm:@esm2cjs/execa@^6.1.1-cjs.1",
|
|
48
|
+
"jest": "^29.5.0",
|
|
49
|
+
"react-native": "^0.72.0",
|
|
50
|
+
"ts-jest": "^29.1.0",
|
|
51
|
+
"ts-node": "^10.9.1",
|
|
52
|
+
"typescript": "^5.0.4"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@react-native-community/cli-tools": "^13.6.5",
|
|
56
|
+
"@react-native/codegen": "0.74.0",
|
|
57
|
+
"@tsconfig/recommended": "^1.0.2",
|
|
58
|
+
"adm-zip": "^0.5.12",
|
|
59
|
+
"case": "^1.6.3",
|
|
60
|
+
"chalk": "^4",
|
|
61
|
+
"commander": "^14.0.0",
|
|
62
|
+
"fs-extra": "^11.1.1",
|
|
63
|
+
"glob": "^10.2.6",
|
|
64
|
+
"ignore": "^5.2.4",
|
|
65
|
+
"inquirer": "^12.7.0",
|
|
66
|
+
"json5": "^2.2.3",
|
|
67
|
+
"memfs": "4.12.0",
|
|
68
|
+
"mustache": "^4.2.0",
|
|
69
|
+
"tar": "^6.1.15",
|
|
70
|
+
"tmp": "^0.2.1",
|
|
71
|
+
"metro": "0.82.5"
|
|
72
|
+
},
|
|
73
|
+
"homepage": "https://gitcode.com/openharmony-sig/ohos_react_native",
|
|
74
|
+
"repository": {
|
|
75
|
+
"type": "gitcode",
|
|
76
|
+
"url": "https://gitcode.com/openharmony-sig/ohos_react_native"
|
|
77
|
+
}
|
|
78
|
+
}
|
package/react-native.config.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { config: harmonyConfig } = require('./dist');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @type {import("@react-native-community/cli-types").Config}
|
|
12
|
-
*/
|
|
13
|
-
const config = {
|
|
14
|
-
commands: harmonyConfig.commands,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
module.exports = config;
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { config: harmonyConfig } = require('./dist');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @type {import("@react-native-community/cli-types").Config}
|
|
12
|
+
*/
|
|
13
|
+
const config = {
|
|
14
|
+
commands: harmonyConfig.commands,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports = config;
|
package/tsconfig.build.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"exclude": [
|
|
4
|
-
"tests",
|
|
5
|
-
"**/*.test.ts",
|
|
6
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"exclude": [
|
|
4
|
+
"tests",
|
|
5
|
+
"**/*.test.ts",
|
|
6
|
+
]
|
|
7
7
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@tsconfig/recommended/tsconfig.json",
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tsconfig/recommended/tsconfig.json",
|
|
3
3
|
}
|
package/.prettierrc
DELETED
package/src/assetResolver.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import pathUtils from 'path';
|
|
9
|
-
import type { AssetData } from 'metro';
|
|
10
|
-
import { Logger } from './io';
|
|
11
|
-
|
|
12
|
-
type Path = string;
|
|
13
|
-
type CopiedFiles = Record<Path, Path>;
|
|
14
|
-
|
|
15
|
-
const ALLOWED_SCALES: number[] = [1, 2, 3, 4];
|
|
16
|
-
|
|
17
|
-
function filterAssetScales(
|
|
18
|
-
scales: readonly number[],
|
|
19
|
-
): readonly number[] {
|
|
20
|
-
const result = scales.filter(scale => ALLOWED_SCALES.includes(scale));
|
|
21
|
-
if (result.length === 0 && scales.length > 0) {
|
|
22
|
-
// No matching scale found, but there are some available. Ideally we don't
|
|
23
|
-
// want to be in this situation and should throw, but for now as a fallback
|
|
24
|
-
// let's just use the closest larger image
|
|
25
|
-
const maxScale = ALLOWED_SCALES[ALLOWED_SCALES.length - 1];
|
|
26
|
-
for (const scale of scales) {
|
|
27
|
-
if (scale > maxScale) {
|
|
28
|
-
result.push(scale);
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// There is no larger scales available, use the largest we have
|
|
33
|
-
if (result.length === 0) {
|
|
34
|
-
result.push(scales[scales.length - 1]);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export async function copyAssets(
|
|
41
|
-
logger: Logger,
|
|
42
|
-
assetsData: readonly AssetData[],
|
|
43
|
-
assetsDest: Path
|
|
44
|
-
): Promise<void> {
|
|
45
|
-
if (assetsDest == null) {
|
|
46
|
-
logger.warn((s) => 'Assets destination folder is not set, skipping...');
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const filesToCopy: CopiedFiles = {};
|
|
51
|
-
const addAssetToCopy = (asset: AssetData) => {
|
|
52
|
-
const validScales = filterAssetScales(asset.scales);
|
|
53
|
-
asset.scales.forEach((scale, idx) => {
|
|
54
|
-
if (!validScales.includes(scale)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const src = asset.files[idx];
|
|
58
|
-
const dest = pathUtils.join(assetsDest, getAssetDestRelativePath(asset, scale));
|
|
59
|
-
filesToCopy[src] = dest;
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
assetsData.forEach(addAssetToCopy);
|
|
64
|
-
|
|
65
|
-
return copyFiles(logger, filesToCopy);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function getAssetDestRelativePath(asset: AssetData, scale: number = 1): string {
|
|
69
|
-
const suffix = scale === 1 ? '' : `@${scale}x`;
|
|
70
|
-
const fileName = getResourceIdentifier(asset);
|
|
71
|
-
// Assets can have relative paths outside of the project root.
|
|
72
|
-
// Replace `../` with `_` to make sure they don't end up outside of
|
|
73
|
-
// the expected assets directory.
|
|
74
|
-
return `${fileName + suffix}.${asset.type}`.replace(/\.\.\//g, '_');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function getResourceIdentifier(asset: AssetData): string {
|
|
78
|
-
const folderPath = getBasePath(asset);
|
|
79
|
-
return `${folderPath}/${asset.name}`.replace(/^assets\//, '');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function getBasePath(asset: AssetData): string {
|
|
83
|
-
const basePath = asset.httpServerLocation;
|
|
84
|
-
return basePath.startsWith('/') ? basePath.slice(1) : basePath;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function copyFiles(logger: Logger, fileDestBySrc: CopiedFiles) {
|
|
88
|
-
const fileSources = Object.keys(fileDestBySrc);
|
|
89
|
-
if (fileSources.length === 0) {
|
|
90
|
-
return Promise.resolve();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const assetFilesCount = fileSources.length;
|
|
94
|
-
return new Promise<void>((resolve, reject) => {
|
|
95
|
-
const copyNext = (error?: Error) => {
|
|
96
|
-
if (error) {
|
|
97
|
-
reject(error);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (fileSources.length === 0) {
|
|
101
|
-
logger.info(
|
|
102
|
-
() =>
|
|
103
|
-
`Copied ${assetFilesCount} ${
|
|
104
|
-
assetFilesCount === 1 ? 'asset' : 'assets'
|
|
105
|
-
}`
|
|
106
|
-
);
|
|
107
|
-
resolve();
|
|
108
|
-
} else {
|
|
109
|
-
// fileSources.length === 0 is checked in previous branch, so this is string
|
|
110
|
-
const src = fileSources.shift()!;
|
|
111
|
-
const dest = fileDestBySrc[src];
|
|
112
|
-
copyFile(src, dest, copyNext);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
copyNext();
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function copyFile(
|
|
120
|
-
src: string,
|
|
121
|
-
dest: string,
|
|
122
|
-
onFinished: (error?: Error) => void
|
|
123
|
-
): void {
|
|
124
|
-
const destDir = pathUtils.dirname(dest);
|
|
125
|
-
fs.mkdir(destDir, { recursive: true }, (err?) => {
|
|
126
|
-
if (err) {
|
|
127
|
-
onFinished(err);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
fs.createReadStream(src)
|
|
131
|
-
.pipe(fs.createWriteStream(dest))
|
|
132
|
-
.on('finish', onFinished);
|
|
133
|
-
});
|
|
134
|
-
}
|