From be5c25eada3237aa6bd7b3390aed9352be8e4e8a Mon Sep 17 00:00:00 2001 From: bqy_fe <1743369777@qq.com> Date: Mon, 6 Mar 2023 19:08:24 +0800 Subject: [PATCH] Fix/publish (#253) * fix: can not require global module --- .github/workflows/release.yml | 2 +- scripts/publish.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2e2f6e74..5fefc5729 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,5 +29,5 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | npm i -g qiniu@6.x - echo "${{ secrets.QINIU_ENV_JS }}" > qiniu_env.js + echo "${{ secrets.QINIU_ENV_JS }}" > ./scripts/qiniu_env.js node scripts/publish.js diff --git a/scripts/publish.js b/scripts/publish.js index 935f13ad4..748d334b5 100644 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -1,4 +1,8 @@ -const qiniu = require('qiniu'); +const { execSync } = require('child_process'); +// get root folder of global node modules +const root = execSync('npm root -g').toString().trim(); + +const qiniu = require(`${root}/qiniu`); const package = require('../package.json'); const { AK, SK, bucket } = require('./qiniu_env.js');