Skip to content

Commit

Permalink
Merge pull request #201 from storyblok/feature/sync-series
Browse files Browse the repository at this point in the history
Serialize sync tasks
  • Loading branch information
onefriendaday authored Feb 21, 2020
2 parents de990d8 + fb9592e commit 5a7068e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"minimist": "^1.2.0",
"netrc": "0.1.4",
"opn": "^5.1.0",
"p-series": "^2.1.0",
"path": "^0.12.7",
"storyblok-js-client": "^2.0.10",
"unirest": "^0.5.1",
Expand Down
13 changes: 7 additions & 6 deletions src/tasks/sync.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const pSeries = require('p-series')
const chalk = require('chalk')
const StoryblokClient = require('storyblok-js-client')
const { capitalize } = require('../utils')
Expand Down Expand Up @@ -218,12 +219,12 @@ const SyncSpaces = {
const sync = (types, options) => {
SyncSpaces.init(options)

return Promise.all(
types.map(_type => {
const command = `sync${capitalize(_type)}`
return SyncSpaces[command]()
})
)
const tasks = types.map(_type => {
const command = `sync${capitalize(_type)}`
return () => SyncSpaces[command]()
})

return pSeries(tasks)
}

module.exports = sync
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==

"@sindresorhus/is@^0.15.0":
version "0.15.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.15.0.tgz#96915baa05e6a6a1d137badf4984d3fc05820bb6"
integrity sha512-lu8BpxjAtRCAo5ifytTpCPCj99LF7o/2Myn+NXyNCBqvPYn7Pjd76AMmUB5l7XF1U6t0hcWrlEM5ESufW7wAeA==

"@szmarczak/http-timer@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421"
Expand Down Expand Up @@ -3649,6 +3654,19 @@ p-reduce@^1.0.0:
resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa"
integrity sha1-GMKw3ZNqRpClKfgjH1ig/bakffo=

p-reduce@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-2.1.0.tgz#09408da49507c6c274faa31f28df334bc712b64a"
integrity sha512-2USApvnsutq8uoxZBGbbWM0JIYLiEMJ9RlaN7fAzVNb9OZN0SHjjTTfIcb667XynS5Y1VhwDJVDa72TnPzAYWw==

p-series@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/p-series/-/p-series-2.1.0.tgz#7035b3a81e2644d4ba407c1ebbc21776e353fa29"
integrity sha512-vEAnkG1ikRT1kPBrKwpj7AFYQkd1hjt/oHeppxtpoPxy5gEt+OWiHZJN3tMqvFa+UJfVwO3lwHoMUpMYBLKnaQ==
dependencies:
"@sindresorhus/is" "^0.15.0"
p-reduce "^2.1.0"

p-try@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
Expand Down

0 comments on commit 5a7068e

Please sign in to comment.