From dadb0dbc6d41ee6633ec9730f6e26c825fd9b93f Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Sat, 27 Mar 2021 11:49:37 +0800 Subject: [PATCH] update --- jd_bean_sign.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/jd_bean_sign.js b/jd_bean_sign.js index ad7403db..29b650ec 100644 --- a/jd_bean_sign.js +++ b/jd_bean_sign.js @@ -261,17 +261,20 @@ function downloadUrl(url = 'https://raw.githubusercontent.com/NobyDa/Script/mast } function requireConfig() { return new Promise(resolve => { - const file = 'jd_bean_sign.js'; - if (process.env.TENCENTCLOUD_RUNENV === 'SCF') { - console.log(`云函数 特有环境变量DEBUG:${process.env.TENCENTCLOUD_RUNENV}`) - } - fs.access(file, fs.constants.W_OK, (err) => { - resultPath = err ? '/tmp/result.txt' : resultPath; - JD_DailyBonusPath = err ? '/tmp/JD_DailyBonus.js' : JD_DailyBonusPath; - outPutUrl = err ? '/tmp/' : outPutUrl; - NodeSet = err ? '/tmp/CookieSet.json' : NodeSet; - resolve() - }); + // const file = 'jd_bean_sign.js'; + // fs.access(file, fs.constants.W_OK, (err) => { + // resultPath = err ? '/tmp/result.txt' : resultPath; + // JD_DailyBonusPath = err ? '/tmp/JD_DailyBonus.js' : JD_DailyBonusPath; + // outPutUrl = err ? '/tmp/' : outPutUrl; + // NodeSet = err ? '/tmp/CookieSet.json' : NodeSet; + // resolve() + // }); + //判断是否是云函数环境。原函数跟目录目录没有可写入权限,文件只能放到根目录下虚拟的/temp/文件夹(具有可写入权限) + resultPath = process.env.TENCENTCLOUD_RUNENV === 'SCF' ? '/tmp/result.txt' : resultPath; + JD_DailyBonusPath = process.env.TENCENTCLOUD_RUNENV === 'SCF' ? '/tmp/JD_DailyBonus.js' : JD_DailyBonusPath; + outPutUrl = process.env.TENCENTCLOUD_RUNENV === 'SCF' ? '/tmp/' : outPutUrl; + NodeSet = process.env.TENCENTCLOUD_RUNENV === 'SCF' ? '/tmp/CookieSet.json' : NodeSet; + resolve() }) } function timeFormat(time) {