File tree Expand file tree Collapse file tree 5 files changed +125
-0
lines changed Expand file tree Collapse file tree 5 files changed +125
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ function prepareWrite(folderResolver, optResolver) {
16
16
return cb ( new Error ( 'Received a non-Vinyl object in `dest()`' ) ) ;
17
17
}
18
18
19
+ // TODO: Remove this after people upgrade vinyl/transition from gulp-util
20
+ if ( typeof file . isSymbolic !== 'function' ) {
21
+ file = new Vinyl ( file ) ;
22
+ }
23
+
19
24
var outFolderPath = folderResolver . resolve ( 'outFolder' , file ) ;
20
25
if ( ! outFolderPath ) {
21
26
return cb ( new Error ( 'Invalid output folder' ) ) ;
Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ function prepareSymlink(folderResolver, optResolver) {
16
16
return cb ( new Error ( 'Received a non-Vinyl object in `symlink()`' ) ) ;
17
17
}
18
18
19
+ // TODO: Remove this after people upgrade vinyl/transition from gulp-util
20
+ if ( typeof file . isSymbolic !== 'function' ) {
21
+ file = new Vinyl ( file ) ;
22
+ }
23
+
19
24
var cwd = path . resolve ( optResolver . resolve ( 'cwd' , file ) ) ;
20
25
21
26
var outFolderPath = folderResolver . resolve ( 'outFolder' , file ) ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ var applyUmask = require('./utils/apply-umask');
16
16
var testStreams = require ( './utils/test-streams' ) ;
17
17
var always = require ( './utils/always' ) ;
18
18
var testConstants = require ( './utils/test-constants' ) ;
19
+ var breakPrototype = require ( './utils/break-prototype' ) ;
19
20
20
21
var from = miss . from ;
21
22
var pipe = miss . pipe ;
@@ -1018,4 +1019,48 @@ describe('.dest()', function() {
1018
1019
concat ( assert ) ,
1019
1020
] , done ) ;
1020
1021
} ) ;
1022
+
1023
+ it ( 'does not marshall a Vinyl object with isSymbolic method' , function ( done ) {
1024
+ var file = new File ( {
1025
+ base : outputBase ,
1026
+ path : outputPath ,
1027
+ } ) ;
1028
+
1029
+ function assert ( files ) {
1030
+ expect ( files . length ) . toEqual ( 1 ) ;
1031
+ // Avoid comparing stats because they get reflected
1032
+ delete files [ 0 ] . stat ;
1033
+ expect ( files [ 0 ] ) . toMatch ( file ) ;
1034
+ expect ( files [ 0 ] ) . toBe ( file ) ;
1035
+ }
1036
+
1037
+ pipe ( [
1038
+ from . obj ( [ file ] ) ,
1039
+ vfs . dest ( outputBase ) ,
1040
+ concat ( assert ) ,
1041
+ ] , done ) ;
1042
+ } ) ;
1043
+
1044
+ it ( 'marshalls a Vinyl object without isSymbolic to a newer Vinyl' , function ( done ) {
1045
+ var file = new File ( {
1046
+ base : outputBase ,
1047
+ path : outputPath ,
1048
+ } ) ;
1049
+
1050
+ breakPrototype ( file ) ;
1051
+
1052
+ function assert ( files ) {
1053
+ expect ( files . length ) . toEqual ( 1 ) ;
1054
+ // Avoid comparing stats because they get reflected
1055
+ delete files [ 0 ] . stat ;
1056
+ expect ( files [ 0 ] ) . toMatch ( file ) ;
1057
+ expect ( files [ 0 ] ) . toNotBe ( file ) ;
1058
+ }
1059
+
1060
+ pipe ( [
1061
+ from . obj ( [ file ] ) ,
1062
+ vfs . dest ( outputBase ) ,
1063
+ concat ( assert ) ,
1064
+ ] , done ) ;
1065
+ } ) ;
1021
1066
} ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ var isWindows = require('./utils/is-windows');
14
14
var testStreams = require ( './utils/test-streams' ) ;
15
15
var always = require ( './utils/always' ) ;
16
16
var testConstants = require ( './utils/test-constants' ) ;
17
+ var breakPrototype = require ( './utils/break-prototype' ) ;
17
18
18
19
var from = miss . from ;
19
20
var pipe = miss . pipe ;
@@ -940,4 +941,50 @@ describe('symlink stream', function() {
940
941
concat ( assert ) ,
941
942
] , done ) ;
942
943
} ) ;
944
+
945
+ it ( 'does not marshall a Vinyl object with isSymbolic method' , function ( done ) {
946
+ var file = new File ( {
947
+ base : outputBase ,
948
+ path : outputPath ,
949
+ } ) ;
950
+
951
+ function assert ( files ) {
952
+ expect ( files . length ) . toEqual ( 1 ) ;
953
+ // Avoid comparing stats because they get reflected
954
+ delete files [ 0 ] . stat ;
955
+ expect ( files [ 0 ] ) . toMatch ( file ) ;
956
+ expect ( files [ 0 ] ) . toBe ( file ) ;
957
+ }
958
+
959
+ pipe ( [
960
+ from . obj ( [ file ] ) ,
961
+ vfs . symlink ( outputBase ) ,
962
+ concat ( assert ) ,
963
+ ] , done ) ;
964
+ } ) ;
965
+
966
+ it ( 'marshalls a Vinyl object without isSymbolic to a newer Vinyl' , function ( done ) {
967
+ var file = new File ( {
968
+ base : outputBase ,
969
+ path : outputPath ,
970
+ // Pre-set this because it is set by symlink
971
+ symlink : outputPath ,
972
+ } ) ;
973
+
974
+ breakPrototype ( file ) ;
975
+
976
+ function assert ( files ) {
977
+ expect ( files . length ) . toEqual ( 1 ) ;
978
+ // Avoid comparing stats because they get reflected
979
+ delete files [ 0 ] . stat ;
980
+ expect ( files [ 0 ] ) . toMatch ( file ) ;
981
+ expect ( files [ 0 ] ) . toNotBe ( file ) ;
982
+ }
983
+
984
+ pipe ( [
985
+ from . obj ( [ file ] ) ,
986
+ vfs . symlink ( outputBase ) ,
987
+ concat ( assert ) ,
988
+ ] , done ) ;
989
+ } ) ;
943
990
} ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ var File = require ( 'vinyl' ) ;
4
+
5
+ function breakPrototype ( file ) {
6
+ // Set up a broken prototype
7
+ var oldProto = { } ;
8
+ Object . getOwnPropertyNames ( File . prototype ) . forEach ( function ( key ) {
9
+ if ( key !== 'isSymbolic' ) {
10
+ var desc = Object . getOwnPropertyDescriptor ( File . prototype , key ) ;
11
+ Object . defineProperty ( oldProto , key , desc ) ;
12
+ }
13
+ } ) ;
14
+
15
+ // Assign the broken prototype to our instance
16
+ if ( typeof Object . setPrototypeOf === 'function' ) {
17
+ Object . setPrototypeOf ( file , oldProto ) ;
18
+ } else {
19
+ file . __proto__ = oldProto ;
20
+ }
21
+ }
22
+
23
+ module . exports = breakPrototype ;
You can’t perform that action at this time.
0 commit comments