Skip to content

Commit

Permalink
feat: add support for building with vue cli
Browse files Browse the repository at this point in the history
  • Loading branch information
nklayman committed Jan 25, 2021
1 parent 2dd3c00 commit c81ac5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ jobs:
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0
- name: install app dependencies and build it
# If using the Vue CLI plugin, tauri:build will be run automatically by tauri-action
# and you can remove `&& yarn build` from this command
run: yarn && yarn build
- uses: tauri-apps/tauri-action@v0
env:
Expand Down Expand Up @@ -149,6 +151,8 @@ jobs:
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0
- name: install app dependencies and build it
# If using the Vue CLI plugin, tauri:build will be run automatically by tauri-action
# and you can remove `&& yarn build` from this command
run: yarn && yarn build
- uses: tauri-apps/tauri-action@v0
env:
Expand Down
18 changes: 11 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ function getPackageJson(root: string): any {
return null
}

function hasTauriDependency(root: string): boolean {
function hasDependency(dependencyName: string, root: string): boolean {
const packageJson = getPackageJson(root)
return (
packageJson &&
((packageJson.dependencies && packageJson.dependencies.tauri) ||
(packageJson.devDependencies && packageJson.devDependencies.tauri))
((packageJson.dependencies && packageJson.dependencies[dependencyName]) ||
(packageJson.devDependencies &&
packageJson.devDependencies[dependencyName]))
)
}

Expand Down Expand Up @@ -73,9 +74,9 @@ async function buildProject(
{configPath, distPath, iconPath, npmScript}: BuildOptions
): Promise<string[]> {
return new Promise<string>(resolve => {
if (core.getInput('preferGlobal') === "true") {
if (core.getInput('preferGlobal') === 'true') {
resolve('tauri')
} else if (hasTauriDependency(root)) {
} else if (hasDependency('tauri', root)) {
if (npmScript) {
resolve(usesYarn(root) ? `yarn ${npmScript}` : `npm run ${npmScript}`)
} else {
Expand Down Expand Up @@ -145,8 +146,11 @@ async function buildProject(
}

const args = debug ? ['--debug'] : []
const buildCommand = hasDependency('vue-cli-plugin-tauri', root)
? (usesYarn(root) ? 'yarn' : 'npm run') + ' tauri:build'
: `${app.runner} build`
return execCommand(
`${app.runner} build` + (args.length ? ` ${args.join(' ')}` : ''),
buildCommand + (args.length ? ` ${args.join(' ')}` : ''),
{cwd: root}
)
.then(() => {
Expand Down Expand Up @@ -298,4 +302,4 @@ async function run(): Promise<void> {
}
}

run()
run()

0 comments on commit c81ac5e

Please sign in to comment.