@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 +1 -1
- package/lib/export.js +12 -1
- package/package.json +2 -2
- package/src/export.js +18 -2
package/LICENSE
CHANGED
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
|
|
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.
|
|
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": "
|
|
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
|
-
|
|
52
|
-
|
|
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
|