braidfs 0.0.70 → 0.0.71
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/index.js +32 -24
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -90,32 +90,40 @@ console.log(`braidfs version: ${require(`${__dirname}/package.json`).version}`)
|
|
|
90
90
|
if (argv.length === 1 && argv[0].match(/^(run|serve)$/)) {
|
|
91
91
|
return main()
|
|
92
92
|
} else if (argv.length && argv.length % 2 == 0 && argv.every((x, i) => i % 2 != 0 || x.match(/^(sync|unsync)$/))) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
93
|
+
return (async () => {
|
|
94
|
+
for (let i = 0; i < argv.length; i += 2) {
|
|
95
|
+
var operation = argv[i],
|
|
96
|
+
url = argv[i + 1]
|
|
97
|
+
if (!url.match(/^https?:\/\//)) {
|
|
98
|
+
if (url.startsWith('/')) url = require('path').relative(proxy_base, url)
|
|
99
|
+
url = `https://${url}`
|
|
100
|
+
}
|
|
101
|
+
console.log(`${operation}ing ${url}`)
|
|
102
|
+
try {
|
|
103
|
+
var res = await braid_fetch(`http://localhost:${config.port}/.braidfs/config`, {
|
|
104
|
+
method: 'PUT',
|
|
105
|
+
patches: [{
|
|
106
|
+
unit: 'json',
|
|
107
|
+
range: `sync[${JSON.stringify(url)}]`,
|
|
108
|
+
content: operation === 'sync' ? 'true' : ''
|
|
109
|
+
}]
|
|
110
|
+
})
|
|
111
|
+
if (res.ok) {
|
|
112
|
+
console.log(`${operation}ed: ${url}`)
|
|
113
|
+
} else {
|
|
114
|
+
console.log(`failed to ${operation} ${url}`)
|
|
115
|
+
console.log(`server responded with ${res.status}: ${await res.text()}`)
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
} catch (e) {
|
|
119
|
+
console.log(`The braidfs daemon does not appear to be running.
|
|
116
120
|
You can run it with:
|
|
117
121
|
braidfs run${to_run_in_background}`)
|
|
118
|
-
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
console.log('All operations completed successfully.')
|
|
126
|
+
})()
|
|
119
127
|
} else {
|
|
120
128
|
return console.log(`Usage:
|
|
121
129
|
braidfs run
|