Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
fix(tcb): optimize conf load logic
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb committed Feb 21, 2021
1 parent 90d3634 commit a4f6307
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 5 additions & 3 deletions serverless/cea/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ async function signIn(usersWithTask) {
return logs
}

async function handler() {
// load config from toml or env
await cea.init()
async function handler(event) {
// load config from toml or env only when we testing
if (!(event.Type === 'Timer')) {
await cea.init()
}
// Log in and save cookie to cea, using cea.get('cookie') to get them (this function resolve with an users array)
const usersWithTask = await cea.handleCookie()
// Sign in
Expand Down
3 changes: 1 addition & 2 deletions src/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ const log = require('../interface/colorLog')
const login = require('../crawler/casLogIn')
const { signApp } = require('../campusphere/app')

// get|store|update cookie synchronizedly, prevent concurrent overlap writes to conf
conf.handleCookie = async () => {
// Return users with curTask
// Return: users with curTask
const usersWithTask = []
await Promise.all(
conf.get('users').map(async i => {
Expand Down

0 comments on commit a4f6307

Please sign in to comment.