@sanity/export 2.27.4-x-dataset-refs.32 → 2.29.5-get-started-template.10

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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2016 - 2021 Sanity.io
3
+ Copyright (c) 2016 - 2022 Sanity.io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/lib/export.js CHANGED
@@ -67,7 +67,14 @@ function exportDataset(opts) {
67
67
  });
68
68
  debug('Outputting assets (temporarily) to %s', tmpDir);
69
69
  debug('Outputting to %s', options.outputPath === '-' ? 'stdout' : options.outputPath);
70
- var outputStream = options.outputPath === '-' ? process.stdout : fse.createWriteStream(options.outputPath);
70
+ var outputStream;
71
+
72
+ if (isWritableStream(options.outputPath)) {
73
+ outputStream = options.outputPath;
74
+ } else {
75
+ outputStream = options.outputPath === '-' ? process.stdout : fse.createWriteStream(options.outputPath);
76
+ }
77
+
71
78
  var assetStreamHandler = assetHandler.noop;
72
79
 
73
80
  if (!options.raw) {
@@ -235,4 +242,8 @@ function exportDataset(opts) {
235
242
  }());
236
243
  }
237
244
 
245
+ function isWritableStream(val) {
246
+ return val !== null && typeof val === 'object' && typeof val.pipe === 'function' && typeof val._write === 'function' && typeof val._writableState === 'object';
247
+ }
248
+
238
249
  module.exports = exportDataset;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/export",
3
- "version": "2.27.4-x-dataset-refs.32+2f4a0f9761",
3
+ "version": "2.29.5-get-started-template.10+5333a7327",
4
4
  "description": "Export Sanity documents and assets",
5
5
  "main": "lib/export.js",
6
6
  "engines": {
@@ -49,5 +49,5 @@
49
49
  "url": "https://github.com/sanity-io/sanity/issues"
50
50
  },
51
51
  "homepage": "https://www.sanity.io/",
52
- "gitHead": "2f4a0f9761dc1b1686d28f1e9e92716cc8372763"
52
+ "gitHead": "5333a7327fcb8e12df1ae74077b1c6ee073170cd"
53
53
  }
package/src/export.js CHANGED
@@ -48,8 +48,14 @@ function exportDataset(opts) {
48
48
 
49
49
  debug('Outputting assets (temporarily) to %s', tmpDir)
50
50
  debug('Outputting to %s', options.outputPath === '-' ? 'stdout' : options.outputPath)
51
- const outputStream =
52
- options.outputPath === '-' ? process.stdout : fse.createWriteStream(options.outputPath)
51
+
52
+ let outputStream
53
+ if (isWritableStream(options.outputPath)) {
54
+ outputStream = options.outputPath
55
+ } else {
56
+ outputStream =
57
+ options.outputPath === '-' ? process.stdout : fse.createWriteStream(options.outputPath)
58
+ }
53
59
 
54
60
  let assetStreamHandler = assetHandler.noop
55
61
  if (!options.raw) {
@@ -195,4 +201,14 @@ function exportDataset(opts) {
195
201
  })
196
202
  }
197
203
 
204
+ function isWritableStream(val) {
205
+ return (
206
+ val !== null &&
207
+ typeof val === 'object' &&
208
+ typeof val.pipe === 'function' &&
209
+ typeof val._write === 'function' &&
210
+ typeof val._writableState === 'object'
211
+ )
212
+ }
213
+
198
214
  module.exports = exportDataset