Skip to content

Commit f643c78

Browse files
committed
fix: fix sourcemapOutput path
1 parent f9a33fc commit f643c78

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

src/bundle/bundle.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,23 @@ export async function bundle(args: BundleArgs) {
3939
}
4040

4141
const bundleReactNative = async (config: BundlerConfig, shouldBuildSourceMaps?: boolean) => {
42-
const { extraBundlerOptions = [], sourcemapOutputDir, extraHermesFlags = [], useHermes = true, outputDir } = config
42+
const {
43+
bundleName,
44+
entryFile,
45+
os,
46+
extraBundlerOptions = [],
47+
sourcemapOutputDir,
48+
sourcemapOutput = path.join(sourcemapOutputDir, bundleName + '.map'),
49+
extraHermesFlags = [],
50+
useHermes = true,
51+
outputDir,
52+
} = config
4353
rmRf(outputDir)
4454
mkdir(outputDir)
45-
rmRf(sourcemapOutputDir)
46-
mkdir(sourcemapOutputDir)
47-
const { bundleName, entryFile, os } = config
48-
const sourcemapOutput = path.join(sourcemapOutputDir, bundleName + '.map')
55+
mkdir(path.dirname(sourcemapOutput))
4956

5057
info(`Using ${config.reinstallNodeModulesCommand} to install node modules`)
51-
execCommand(config.reinstallNodeModulesCommand)
58+
await execCommand(config.reinstallNodeModulesCommand)
5259

5360
await runReactNativeBundleCommand(
5461
bundleName,
@@ -73,7 +80,7 @@ const bundleReactNative = async (config: BundlerConfig, shouldBuildSourceMaps?:
7380
const checkoutAndBuild = async (bundlerConfig: BundlerConfig, commit: string) => {
7481
try {
7582
await fetchOrigin()
76-
checkout(commit)
83+
await checkout(commit)
7784
const output = await bundleReactNative(bundlerConfig, false)
7885

7986
return output

src/bundle/utils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { execSync } from 'child_process'
1+
import child from 'child_process'
2+
import util from 'util'
23
import * as fs from 'fs'
34
import { tmpdir } from 'os'
45
import * as Path from 'path'
@@ -39,7 +40,12 @@ export function defaultEntryFile(platform: string): string {
3940
throw new Error(`Entry file "index.${platform}.js" or "index.js" does not exist.`)
4041
}
4142

42-
export const execCommand = (command: string) => execSync(command).toString().trim()
43+
export async function execCommand(command: string) {
44+
const exec = util.promisify(child.exec)
45+
const result = await exec(command)
46+
47+
return result
48+
}
4349

4450
export function fileExists(file: fs.PathLike) {
4551
try {
@@ -68,7 +74,7 @@ export function installNodeModulesCommand() {
6874

6975
export function getPlatform(app: string): string {
7076
const command = `appcenter apps show --app ${app} --output json`
71-
const json = JSON.parse(execCommand(command))
77+
const json = JSON.parse(child.execSync(command).toString().trim())
7278

7379
return json.os.toLowerCase()
7480
}

0 commit comments

Comments
 (0)