|  | 
|  | 1 | +// Jest Snapshot v1, https://goo.gl/fbAQLP | 
|  | 2 | + | 
|  | 3 | +exports[`Test rebase-zero: 00: rebase to zero 1`] = ` | 
|  | 4 | +"SNAPSHOT: rebase to zero | 
|  | 5 | +patch-package 0.0.0 | 
|  | 6 | +Un-applied left-pad+1.3.0+003+goodbye.patch | 
|  | 7 | +Un-applied left-pad+1.3.0+002+world.patch | 
|  | 8 | +Un-applied left-pad+1.3.0+001+hello.patch | 
|  | 9 | +
 | 
|  | 10 | +Make any changes you need inside node_modules/left-pad | 
|  | 11 | +
 | 
|  | 12 | +When you are done, run | 
|  | 13 | +
 | 
|  | 14 | +  patch-package left-pad --append 'MyChangeDescription' | 
|  | 15 | +   | 
|  | 16 | +to insert a new patch file. | 
|  | 17 | +
 | 
|  | 18 | +END SNAPSHOT" | 
|  | 19 | +`; | 
|  | 20 | + | 
|  | 21 | +exports[`Test rebase-zero: 01: it creates a new patch at the start and renames all the other patches, applying them 1`] = ` | 
|  | 22 | +"SNAPSHOT: it creates a new patch at the start and renames all the other patches, applying them | 
|  | 23 | +patch-package 0.0.0 | 
|  | 24 | +β’ Creating temporary folder | 
|  | 25 | +β’ Installing [email protected] with npm | 
|  | 26 | +β’ Diffing your files with clean files | 
|  | 27 | +β Created file patches/left-pad+1.3.0+001+WhileOne.patch | 
|  | 28 | +
 | 
|  | 29 | +Renaming left-pad+1.3.0+001+hello.patch to left-pad+1.3.0+002+hello.patch | 
|  | 30 | +Renaming left-pad+1.3.0+002+world.patch to left-pad+1.3.0+003+world.patch | 
|  | 31 | +Renaming left-pad+1.3.0+003+goodbye.patch to left-pad+1.3.0+004+goodbye.patch | 
|  | 32 | +Fast forwarding... | 
|  | 33 | +  β left-pad+1.3.0+002+hello.patch | 
|  | 34 | +  β left-pad+1.3.0+003+world.patch | 
|  | 35 | +  β left-pad+1.3.0+004+goodbye.patch | 
|  | 36 | +left-pad+1.3.0+001+WhileOne.patch | 
|  | 37 | +left-pad+1.3.0+002+hello.patch | 
|  | 38 | +left-pad+1.3.0+003+world.patch | 
|  | 39 | +left-pad+1.3.0+004+goodbye.patch | 
|  | 40 | +the state file | 
|  | 41 | +{ | 
|  | 42 | +    \\"isRebasing\\": false, | 
|  | 43 | +    \\"patches\\": [ | 
|  | 44 | +        { | 
|  | 45 | +            \\"didApply\\": true, | 
|  | 46 | +            \\"patchContentHash\\": \\"dfc6e6951dc7d5bf2e1768a353933c73ba6bccd76c7927d28384107f3be2e8eb\\", | 
|  | 47 | +            \\"patchFilename\\": \\"left-pad+1.3.0+001+WhileOne.patch\\" | 
|  | 48 | +        }, | 
|  | 49 | +        { | 
|  | 50 | +            \\"didApply\\": true, | 
|  | 51 | +            \\"patchContentHash\\": \\"404c604ed830db6a0605f86cb9165ced136848f70986b23bf877bcf38968c1c9\\", | 
|  | 52 | +            \\"patchFilename\\": \\"left-pad+1.3.0+002+hello.patch\\" | 
|  | 53 | +        }, | 
|  | 54 | +        { | 
|  | 55 | +            \\"didApply\\": true, | 
|  | 56 | +            \\"patchContentHash\\": \\"f2859c7193de8d9578bdde7e226de516adc8d972d6e76997cbe1f41b1a535359\\", | 
|  | 57 | +            \\"patchFilename\\": \\"left-pad+1.3.0+003+world.patch\\" | 
|  | 58 | +        }, | 
|  | 59 | +        { | 
|  | 60 | +            \\"didApply\\": true, | 
|  | 61 | +            \\"patchContentHash\\": \\"c9063ed6ae00867ee243fa71590c369ce0bb699f3a63a10df86d3ec988782715\\", | 
|  | 62 | +            \\"patchFilename\\": \\"left-pad+1.3.0+004+goodbye.patch\\" | 
|  | 63 | +        } | 
|  | 64 | +    ], | 
|  | 65 | +    \\"version\\": 1 | 
|  | 66 | +}the js file | 
|  | 67 | +/* This program is free software. It comes without any warranty, to | 
|  | 68 | +     * the extent permitted by applicable law. You can redistribute it | 
|  | 69 | +     * and/or modify it under the terms of the Do What The Fuck You Want | 
|  | 70 | +     * To Public License, Version 2, as published by Sam Hocevar. See | 
|  | 71 | +     * http://www.wtfpl.net/ for more details. */ | 
|  | 72 | +'goodbye world'; | 
|  | 73 | +module.exports = leftPad; | 
|  | 74 | +
 | 
|  | 75 | +var cache = [ | 
|  | 76 | +  '', | 
|  | 77 | +  ' ', | 
|  | 78 | +  '  ', | 
|  | 79 | +  '   ', | 
|  | 80 | +  '    ', | 
|  | 81 | +  '     ', | 
|  | 82 | +  '      ', | 
|  | 83 | +  '       ', | 
|  | 84 | +  '        ', | 
|  | 85 | +  '         ' | 
|  | 86 | +]; | 
|  | 87 | +
 | 
|  | 88 | +function leftPad (str, len, ch) { | 
|  | 89 | +  // convert \`str\` to a \`string\` | 
|  | 90 | +  str = str + ''; | 
|  | 91 | +  // \`len\` is the \`pad\`'s length now | 
|  | 92 | +  len = len - str.length; | 
|  | 93 | +  // doesn't need to pad | 
|  | 94 | +  if (len <= 0) return str; | 
|  | 95 | +  // \`ch\` defaults to \`' '\` | 
|  | 96 | +  if (!ch && ch !== 0) ch = ' '; | 
|  | 97 | +  // convert \`ch\` to a \`string\` cuz it could be a number | 
|  | 98 | +  ch = ch + ''; | 
|  | 99 | +  // cache common use cases | 
|  | 100 | +  if (ch === ' ' && len < 10) return cache[len] + str; | 
|  | 101 | +  // \`pad\` starts with an empty string | 
|  | 102 | +  var pad = ''; | 
|  | 103 | +  // loop | 
|  | 104 | +  while (1) { | 
|  | 105 | +    // add \`ch\` to \`pad\` if \`len\` is odd | 
|  | 106 | +    if (len & 1) pad += ch; | 
|  | 107 | +    // divide \`len\` by 2, ditch the remainder | 
|  | 108 | +    len >>= 1; | 
|  | 109 | +    // \\"double\\" the \`ch\` so this operation count grows logarithmically on \`len\` | 
|  | 110 | +    // each time \`ch\` is \\"doubled\\", the \`len\` would need to be \\"doubled\\" too | 
|  | 111 | +    // similar to finding a value in binary search tree, hence O(log(n)) | 
|  | 112 | +    if (len) ch += ch; | 
|  | 113 | +    // \`len\` is 0, exit the loop | 
|  | 114 | +    else break; | 
|  | 115 | +  } | 
|  | 116 | +  // pad \`str\`! | 
|  | 117 | +  return pad + str; | 
|  | 118 | +} | 
|  | 119 | +END SNAPSHOT" | 
|  | 120 | +`; | 
|  | 121 | + | 
|  | 122 | +exports[`Test rebase-zero: 02: rebase to zero again 1`] = ` | 
|  | 123 | +"SNAPSHOT: rebase to zero again | 
|  | 124 | +patch-package 0.0.0 | 
|  | 125 | +Un-applied left-pad+1.3.0+004+goodbye.patch | 
|  | 126 | +Un-applied left-pad+1.3.0+003+world.patch | 
|  | 127 | +Un-applied left-pad+1.3.0+002+hello.patch | 
|  | 128 | +Un-applied left-pad+1.3.0+001+WhileOne.patch | 
|  | 129 | +
 | 
|  | 130 | +Make any changes you need inside node_modules/left-pad | 
|  | 131 | +
 | 
|  | 132 | +When you are done, run | 
|  | 133 | +
 | 
|  | 134 | +  patch-package left-pad --append 'MyChangeDescription' | 
|  | 135 | +   | 
|  | 136 | +to insert a new patch file. | 
|  | 137 | +
 | 
|  | 138 | +END SNAPSHOT" | 
|  | 139 | +`; | 
|  | 140 | + | 
|  | 141 | +exports[`Test rebase-zero: 03: it creates a new patch at the start called 'initial' if you dont do --append 1`] = ` | 
|  | 142 | +"SNAPSHOT: it creates a new patch at the start called 'initial' if you dont do --append | 
|  | 143 | +patch-package 0.0.0 | 
|  | 144 | +β’ Creating temporary folder | 
|  | 145 | +β’ Installing [email protected] with npm | 
|  | 146 | +β’ Diffing your files with clean files | 
|  | 147 | +β Created file patches/left-pad+1.3.0+001+initial.patch | 
|  | 148 | +
 | 
|  | 149 | +Renaming left-pad+1.3.0+001+WhileOne.patch to left-pad+1.3.0+002+WhileOne.patch | 
|  | 150 | +Renaming left-pad+1.3.0+002+hello.patch to left-pad+1.3.0+003+hello.patch | 
|  | 151 | +Renaming left-pad+1.3.0+003+world.patch to left-pad+1.3.0+004+world.patch | 
|  | 152 | +Renaming left-pad+1.3.0+004+goodbye.patch to left-pad+1.3.0+005+goodbye.patch | 
|  | 153 | +Fast forwarding... | 
|  | 154 | +  β left-pad+1.3.0+002+WhileOne.patch | 
|  | 155 | +  β left-pad+1.3.0+003+hello.patch | 
|  | 156 | +  β left-pad+1.3.0+004+world.patch | 
|  | 157 | +  β left-pad+1.3.0+005+goodbye.patch | 
|  | 158 | +left-pad+1.3.0+001+initial.patch | 
|  | 159 | +left-pad+1.3.0+002+WhileOne.patch | 
|  | 160 | +left-pad+1.3.0+003+hello.patch | 
|  | 161 | +left-pad+1.3.0+004+world.patch | 
|  | 162 | +left-pad+1.3.0+005+goodbye.patch | 
|  | 163 | +END SNAPSHOT" | 
|  | 164 | +`; | 
0 commit comments