remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/bin/remixd

47 lines
1.8 KiB

#!/usr/bin/env node
var Router = require('../src/router')
var servicesList = require('../src/servicesList')
var program = require('commander')
program
7 years ago
.usage('-s <shared folder>')
6 years ago
.description('Provide a two-way connection between the local computer and Remix IDE')
.option('--remix-ide <url>', 'URL of remix instance allowed to connect to this web sockect connection')
.option('-s, --shared-folder <path>', 'Folder to share with Remix IDE')
.option('--read-only', 'Treat shared folder as read-only (experimental)')
.on('--help', function(){
console.log('\nExample:\n\n remixd -s ./ --remix-ide http://localhost:8080')
}).parse(process.argv)
var killCallBack = []
if (!program.remixIde) {
return console.log('\x1b[31m%s\x1b[0m', '[ERR] URL Remix IDE instance has to be provided.')
}
console.log('\x1b[33m%s\x1b[0m', '[WARN] You may now only use IDE at ' + program.remixIde + ' to connect to that instance')
if (program.sharedFolder) {
console.log('\x1b[33m%s\x1b[0m', '[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.')
console.log('\x1b[33m%s\x1b[0m', '[WARN] Symbolic links are not forwarded to Remix IDE\n')
var sharedFolderrouter = new Router(65520, servicesList['sharedfolder'], { remixIdeUrl: program.remixIde }, (webSocket) => {
servicesList['sharedfolder'].setWebSocket(webSocket)
servicesList['sharedfolder'].setupNotifications(program.sharedFolder)
servicesList['sharedfolder'].sharedFolder(program.sharedFolder, program.readOnly || false)
})
killCallBack.push(sharedFolderrouter.start())
}
// kill
function kill () {
for (var k in killCallBack) {
try {
killCallBack[k]()
} catch (e) {
console.log(e)
}
}
}
process.on('SIGINT', kill) // catch ctrl-c
process.on('SIGTERM', kill) // catch kill
process.on('exit', kill)