-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(electron): make npx cap open electron run electron app (#1666)
* Fix(electron): make npx cap open electron run electron app * document change
- Loading branch information
1 parent
cf09bb4
commit 5252f8f
Showing
3 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { exec } from 'child_process'; | ||
import { Config } from '../config'; | ||
import { logInfo } from '../common'; | ||
import { existsAsync } from '../util/fs'; | ||
import { resolve } from 'path'; | ||
|
||
export async function openElectron(config: Config) { | ||
|
||
const dir = config.electron.platformDir; | ||
|
||
logInfo(`Opening Electron project at ${dir}`); | ||
|
||
if (!await existsAsync(resolve(config.app.rootDir, dir))) { | ||
throw new Error('Electron project does not exist. Create one with "npx cap add electron"'); | ||
} | ||
|
||
return new Promise(async (resolve, reject) => { | ||
exec(`npm run electron:start`, {cwd: dir}, (error) => { | ||
if (error) { | ||
reject(error); | ||
return; | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters