MCPcopy Index your code
hub / github.com/deployd/deployd / save

Function save

lib/resources/internal-resources.js:121–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119 });
120
121 function save() {
122 if (isJson && !resource.$setAll) {
123 fs.readFile(file, 'utf-8', function(err, currentValue) {
124 if (!currentValue) {
125 writeFile(resource);
126 } else {
127 try {
128 var currentJson = JSON.parse(currentValue);
129 Object.keys(resource).forEach(function(k) {
130 currentJson[k] = resource[k];
131 });
132 writeFile(currentJson);
133 } catch (ex) {
134 writeFile(resource);
135 }
136 }
137 });
138 } else if (isJson) {
139 delete resource.$setAll;
140 writeFile(resource);
141 } else {
142 writeFile(resource.value);
143 }
144 }
145
146 function writeFile(value) {
147 var newId = value.id;

Callers 1

Calls 1

writeFileFunction · 0.85

Tested by

no test coverage detected