Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

Commit 5a7068e

Browse files
Merge pull request #201 from storyblok/feature/sync-series
Serialize sync tasks
2 parents de990d8 + fb9592e commit 5a7068e

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"minimist": "^1.2.0",
3232
"netrc": "0.1.4",
3333
"opn": "^5.1.0",
34+
"p-series": "^2.1.0",
3435
"path": "^0.12.7",
3536
"storyblok-js-client": "^2.0.10",
3637
"unirest": "^0.5.1",

src/tasks/sync.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const pSeries = require('p-series')
12
const chalk = require('chalk')
23
const StoryblokClient = require('storyblok-js-client')
34
const { capitalize } = require('../utils')
@@ -218,12 +219,12 @@ const SyncSpaces = {
218219
const sync = (types, options) => {
219220
SyncSpaces.init(options)
220221

221-
return Promise.all(
222-
types.map(_type => {
223-
const command = `sync${capitalize(_type)}`
224-
return SyncSpaces[command]()
225-
})
226-
)
222+
const tasks = types.map(_type => {
223+
const command = `sync${capitalize(_type)}`
224+
return () => SyncSpaces[command]()
225+
})
226+
227+
return pSeries(tasks)
227228
}
228229

229230
module.exports = sync

yarn.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@
299299
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
300300
integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==
301301

302+
"@sindresorhus/is@^0.15.0":
303+
version "0.15.0"
304+
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.15.0.tgz#96915baa05e6a6a1d137badf4984d3fc05820bb6"
305+
integrity sha512-lu8BpxjAtRCAo5ifytTpCPCj99LF7o/2Myn+NXyNCBqvPYn7Pjd76AMmUB5l7XF1U6t0hcWrlEM5ESufW7wAeA==
306+
302307
"@szmarczak/http-timer@^1.1.2":
303308
version "1.1.2"
304309
resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421"
@@ -3649,6 +3654,19 @@ p-reduce@^1.0.0:
36493654
resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa"
36503655
integrity sha1-GMKw3ZNqRpClKfgjH1ig/bakffo=
36513656

3657+
p-reduce@^2.1.0:
3658+
version "2.1.0"
3659+
resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-2.1.0.tgz#09408da49507c6c274faa31f28df334bc712b64a"
3660+
integrity sha512-2USApvnsutq8uoxZBGbbWM0JIYLiEMJ9RlaN7fAzVNb9OZN0SHjjTTfIcb667XynS5Y1VhwDJVDa72TnPzAYWw==
3661+
3662+
p-series@^2.1.0:
3663+
version "2.1.0"
3664+
resolved "https://registry.yarnpkg.com/p-series/-/p-series-2.1.0.tgz#7035b3a81e2644d4ba407c1ebbc21776e353fa29"
3665+
integrity sha512-vEAnkG1ikRT1kPBrKwpj7AFYQkd1hjt/oHeppxtpoPxy5gEt+OWiHZJN3tMqvFa+UJfVwO3lwHoMUpMYBLKnaQ==
3666+
dependencies:
3667+
"@sindresorhus/is" "^0.15.0"
3668+
p-reduce "^2.1.0"
3669+
36523670
p-try@^1.0.0:
36533671
version "1.0.0"
36543672
resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"

0 commit comments

Comments
 (0)