Compare commits
2 Commits
b41f37efa7
...
a9cf2a1d21
Author | SHA1 | Date |
---|---|---|
b1ek | a9cf2a1d21 | |
b1ek | 33b23ec1ad |
|
@ -21,6 +21,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@parcel/fs": "^2.8.3",
|
"@parcel/fs": "^2.8.3",
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
|
"file-saver": "^2.0.5",
|
||||||
"memfs": "^3.4.13",
|
"memfs": "^3.4.13",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
import { Terminal } from 'xterm';
|
||||||
|
import { saveAs } from 'file-saver';
|
||||||
|
const fs = require('../fs');
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param { string[] } argv
|
||||||
|
* @param { Terminal } terminal
|
||||||
|
*/
|
||||||
|
module.exports = (argv, terminal) => {
|
||||||
|
if (argv.indexOf('--help') != -1 || argv.length == 1) {
|
||||||
|
terminal.write(
|
||||||
|
`Usage: ${argv[0]} [FILES] [-z]
|
||||||
|
Export file from filesystem to your device.
|
||||||
|
-z Compress in zip format (not supported)`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let files = [...argv];
|
||||||
|
files.shift();
|
||||||
|
|
||||||
|
if (argv.indexOf('-z') != -1) {
|
||||||
|
terminal.write(`${argv[0]}: cannot zip '${files.join(' ').replace('\'', "\\'")}': not supported\n`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var isFileSaverSupported = !!new Blob;
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
if (!isFileSaverSupported) {
|
||||||
|
terminal.write(`${argv[0]}: Your browser does not support this feature.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fs.existsSync(argv[1])) {
|
||||||
|
terminal.write(`${argv[0]}: cannot open ${argv[1]}: no such file or directory\n`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
saveAs(new Blob([fs.readFileSync(argv[1])]), argv[1]);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ let cmds = {
|
||||||
'skills': require('./skills'),
|
'skills': require('./skills'),
|
||||||
'mkdir': require('./mkdir'),
|
'mkdir': require('./mkdir'),
|
||||||
'wget': require('./wget'),
|
'wget': require('./wget'),
|
||||||
|
'export_file': require('./export_file'),
|
||||||
|
|
||||||
// alias l='ls -l'
|
// alias l='ls -l'
|
||||||
'l': (a,t) => {require('./ls')([...a, '-l'], t)},
|
'l': (a,t) => {require('./ls')([...a, '-l'], t)},
|
||||||
|
|
|
@ -41,7 +41,7 @@ Usage: ${argv[0]} [URL] [-O out.file] [-V] [-Q] [-s]
|
||||||
if (filepath == '-') {
|
if (filepath == '-') {
|
||||||
terminal.write(file);
|
terminal.write(file);
|
||||||
} else {
|
} else {
|
||||||
fs.writeFileSync(filepath, file);
|
fs.writeFileSync(filepath, new Buffer(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ Usage: ${argv[0]} [URL] [-O out.file] [-V] [-Q] [-s]
|
||||||
req.onprogress = progress;
|
req.onprogress = progress;
|
||||||
req.onload = (e) => {
|
req.onload = (e) => {
|
||||||
if (e.type == 'load') {
|
if (e.type == 'load') {
|
||||||
write(e.response);
|
write(req.response);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
req.send();
|
req.send();
|
||||||
|
|
Loading…
Reference in New Issue