@npmcli/arborist 4.1.2 → 4.2.0
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/lib/shrinkwrap.js +15 -4
- package/package.json +1 -1
package/lib/shrinkwrap.js
CHANGED
|
@@ -1085,18 +1085,29 @@ class Shrinkwrap {
|
|
|
1085
1085
|
return lock
|
|
1086
1086
|
}
|
|
1087
1087
|
|
|
1088
|
-
|
|
1088
|
+
toJSON () {
|
|
1089
1089
|
if (!this.data) {
|
|
1090
|
-
throw new Error('run load() before
|
|
1090
|
+
throw new Error('run load() before getting or setting data')
|
|
1091
1091
|
}
|
|
1092
1092
|
|
|
1093
|
+
return this.commit()
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
toString (options = {}) {
|
|
1097
|
+
const data = this.toJSON()
|
|
1093
1098
|
const { format = true } = options
|
|
1094
1099
|
const defaultIndent = this.indent || 2
|
|
1095
1100
|
const indent = format === true ? defaultIndent
|
|
1096
1101
|
: format || 0
|
|
1097
1102
|
const eol = format ? this.newline || '\n' : ''
|
|
1098
|
-
|
|
1099
|
-
|
|
1103
|
+
return stringify(data, swKeyOrder, indent).replace(/\n/g, eol)
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
save (options = {}) {
|
|
1107
|
+
if (!this.data) {
|
|
1108
|
+
throw new Error('run load() before saving data')
|
|
1109
|
+
}
|
|
1110
|
+
const json = this.toString(options)
|
|
1100
1111
|
return Promise.all([
|
|
1101
1112
|
writeFile(this.filename, json).catch(er => {
|
|
1102
1113
|
if (this.hiddenLockfile) {
|