braidfs 0.0.77 → 0.0.78
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 +4 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -61,24 +61,24 @@ if (argv.length === 1 && argv[0].match(/^(run|serve)$/)) {
|
|
|
61
61
|
} else if (argv.length && argv.length % 2 == 0 && argv.every((x, i) => i % 2 != 0 || x.match(/^(sync|unsync)$/))) {
|
|
62
62
|
return (async () => {
|
|
63
63
|
for (let i = 0; i < argv.length; i += 2) {
|
|
64
|
-
var
|
|
64
|
+
var sync = argv[i] === 'sync',
|
|
65
65
|
url = argv[i + 1]
|
|
66
66
|
if (!url.match(/^https?:\/\//)) {
|
|
67
67
|
if (url.startsWith('/')) url = require('path').relative(proxy_base, url)
|
|
68
68
|
url = `https://${url}`
|
|
69
69
|
}
|
|
70
|
-
console.log(`${
|
|
70
|
+
console.log(`${sync ? '' : 'un'}subscribing ${sync ? 'to' : 'from'} ${url}`)
|
|
71
71
|
try {
|
|
72
72
|
var res = await braid_fetch(`http://localhost:${config.port}/.braidfs/config`, {
|
|
73
73
|
method: 'PUT',
|
|
74
74
|
patches: [{
|
|
75
75
|
unit: 'json',
|
|
76
76
|
range: `sync[${JSON.stringify(url)}]`,
|
|
77
|
-
content:
|
|
77
|
+
content: sync ? 'true' : ''
|
|
78
78
|
}]
|
|
79
79
|
})
|
|
80
80
|
if (res.ok) {
|
|
81
|
-
console.log(
|
|
81
|
+
console.log(`Now ${sync ? '' : 'un'}subscribed ${sync ? 'to' : 'from'} ${url} in ~/http/.braidfs/config`)
|
|
82
82
|
} else {
|
|
83
83
|
console.log(`failed to ${operation} ${url}`)
|
|
84
84
|
console.log(`server responded with ${res.status}: ${await res.text()}`)
|
|
@@ -91,7 +91,6 @@ You can run it with:
|
|
|
91
91
|
return
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
console.log('All operations completed successfully.')
|
|
95
94
|
})()
|
|
96
95
|
} else {
|
|
97
96
|
return console.log(`Usage:
|