Skip to content

Commit

Permalink
feat: set NPM_CLIENT when midway deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuang committed Mar 17, 2024
1 parent 7bccf6a commit 715799f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/plugin-midway/src/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { promises as fs } from 'fs'
import { join } from 'path'
import { getCwd, isFaaS, judgeVersion, logGreen } from 'ssr-common-utils'
import { getCwd, isFaaS, judgeVersion, logGreen, accessFile } from 'ssr-common-utils'
import { Argv } from 'ssr-types'

const cwd = getCwd()
Expand All @@ -19,6 +19,15 @@ const deploy = async (argv: Argv) => {

logGreen('If you find some problems when deploy, see http://doc.ssr-fc.com/docs/features$faq#Serverless%20%E5%8F%91%E5%B8%83%E5%A4%B1%E8%B4%A5')
const { cli } = require('@midwayjs/cli/bin/cli')
if (await accessFile(join(cwd, './package-lock.json'))) {
process.env.NPM_CLIENT = 'npm'
}
if (await accessFile(join(cwd, './yarn.lock'))) {
process.env.NPM_CLIENT = 'yarn'
}
if (await accessFile(join(cwd, './pnpm-lock.yaml'))) {
process.env.NPM_CLIENT = 'pnpm'
}
argv._[0] = 'deploy'
await cli(argv)
}
Expand Down

0 comments on commit 715799f

Please sign in to comment.