Skip to content

Commit

Permalink
add node env in cli file and change package.json bin to same like REA…
Browse files Browse the repository at this point in the history
…DME (#4)

Co-authored-by: Xu Yinjie <[email protected]>
  • Loading branch information
xyj404 and Xu Yinjie authored Nov 25, 2020
1 parent c656801 commit 772de13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "transform rrweb session into video",
"main": "build/index.js",
"bin": {
"vtc": "build/cli.js"
"rrvideo": "build/cli.js"
},
"files": [
"build"
Expand Down
17 changes: 9 additions & 8 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as fs from "fs";
import * as path from "path";
import minimist from "minimist";
import { transformToVideo } from "./index";
#!/usr/bin/env node
import * as fs from 'fs';
import * as path from 'path';
import minimist from 'minimist';
import { transformToVideo } from './index';

const argv = minimist(process.argv.slice(2));

if (!argv.input) {
throw new Error("please pass --input to your rrweb events file");
throw new Error('please pass --input to your rrweb events file');
}

let config = {};
Expand All @@ -15,19 +16,19 @@ if (argv.config) {
const configPath = path.isAbsolute(argv.config)
? argv.config
: path.resolve(process.cwd(), argv.config);
config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
}

transformToVideo({
input: argv.input,
output: argv.output,
rrwebPlayer: config,
rrwebPlayer: config
})
.then((file) => {
console.log(`Successfully transformed into "${file}".`);
})
.catch((error) => {
console.log("Failed to transform this session.");
console.log('Failed to transform this session.');
console.error(error);
process.exit(1);
});

0 comments on commit 772de13

Please sign in to comment.