@sanity/export 3.38.0 → 3.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/export.js +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/export",
3
- "version": "3.38.0",
3
+ "version": "3.38.1",
4
4
  "description": "Export Sanity documents and assets",
5
5
  "keywords": [
6
6
  "sanity",
package/src/export.js CHANGED
@@ -39,6 +39,9 @@ async function exportDataset(opts) {
39
39
 
40
40
  const prefix = `${opts.dataset}-export-${slugDate}`
41
41
  const tmpDir = path.join(os.tmpdir(), prefix)
42
+ fs.mkdirSync(tmpDir, {recursive: true})
43
+ const dataPath = path.join(tmpDir, 'data.ndjson')
44
+
42
45
  const cleanup = () =>
43
46
  rimraf(tmpDir).catch((err) => {
44
47
  debug(`Error while cleaning up temporary files: ${err.message}`)
@@ -126,7 +129,7 @@ async function exportDataset(opts) {
126
129
  miss.through(reportDocumentCount),
127
130
  )
128
131
 
129
- miss.finished(jsonStream, async (err) => {
132
+ miss.pipe(jsonStream, fs.createWriteStream(dataPath), async (err) => {
130
133
  if (err) {
131
134
  debug('Export stream error: ', err)
132
135
  reject(err)
@@ -141,6 +144,9 @@ async function exportDataset(opts) {
141
144
  update: true,
142
145
  })
143
146
 
147
+ debug('Adding data.ndjson to archive')
148
+ archive.file(dataPath, {name: 'data.ndjson', prefix})
149
+
144
150
  if (!options.raw && options.assets) {
145
151
  onProgress({step: 'Downloading assets...'})
146
152
  }
@@ -197,7 +203,6 @@ async function exportDataset(opts) {
197
203
  debug('Archive warning: %s', err.message)
198
204
  })
199
205
 
200
- archive.append(jsonStream, {name: 'data.ndjson', prefix})
201
206
  miss.pipe(archive, outputStream, onComplete)
202
207
 
203
208
  async function onComplete(err) {
@@ -205,6 +210,7 @@ async function exportDataset(opts) {
205
210
  await cleanup()
206
211
 
207
212
  if (!err) {
213
+ debug('Export completed')
208
214
  resolve({
209
215
  outputPath: options.outputPath,
210
216
  documentCount,