lbry-format/lbry-format.js

66 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-03-29 03:49:05 +01:00
#!/usr/bin/env node
2019-06-23 21:58:00 +02:00
const { packDirectory, unpackDirectory } = require("lbry-format");
const path = require("path");
2019-03-29 03:49:05 +01:00
2019-06-23 21:58:00 +02:00
require("yargs")
2019-12-26 18:40:25 +01:00
.scriptName("lbry-format")
2019-06-23 21:58:00 +02:00
.usage("$0 <cmd> [args]")
.command(
"pack [directory] [file] [-t]",
"Pack a directory",
yargs => {
yargs
.positional("directory", {
default: "./src",
describe: "The source directory to pack"
})
.positional("file", {
describe: "Output file",
default: "./package.lbry"
})
.option("t", {
alias: "template",
describe: "Use web template"
});
},
function(argv) {
console.log(`Packing ${argv.directory} to ${argv.file}`);
2019-03-29 03:49:05 +01:00
2019-06-23 21:58:00 +02:00
const resolvedDirectory = path.resolve(argv.directory);
const resolvedfile = path.resolve(argv.file);
2019-03-29 03:49:05 +01:00
2019-06-23 21:58:00 +02:00
packDirectory(resolvedDirectory, {
fileName: resolvedfile,
useTemplate: argv.template
});
}
)
.command(
"unpack [directory] [file]",
"Unpack a file",
yargs => {
yargs
.positional("destination", {
type: "string",
default: "./src",
describe: "The folder destination to unpack to"
})
.positional("file", {
describe: "Input filename",
default: "package.lbry"
});
},
function(argv) {
console.log(`Packing ${argv.directory} to ${argv.file}`);
2019-03-29 03:49:05 +01:00
2019-06-23 21:58:00 +02:00
const resolvedDirectory = path.resolve(argv.directory);
const resolvedfile = path.resolve(argv.file);
2019-03-29 03:49:05 +01:00
2019-06-23 21:58:00 +02:00
unpackDirectory(resolvedDirectory, {
fileName: resolvedfile
});
}
)
2019-03-29 03:49:05 +01:00
.help()
2019-06-23 21:58:00 +02:00
.demandCommand().argv;