-
Notifications
You must be signed in to change notification settings - Fork 460
Expand file tree
/
Copy pathrun.js
More file actions
47 lines (44 loc) · 1.23 KB
/
run.js
File metadata and controls
47 lines (44 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const $ = require('gogocode');
const t = require('../index');
const path = require('path');
const fs = require('fs');
const inputPath = path.resolve(__dirname, './input.js');
const outputPath = path.resolve(__dirname, './output/no-config.js');
const outputPathWithConfig = path.resolve(__dirname, './output/custom-config.js');
fs.readFile(inputPath, function read(err, code) {
if (err) {
throw err;
}
const outputCode = t(
{
source: code.toString(),
path: inputPath
},
{
gogocode: $
},
{
rootPath: __dirname,
outFilePath: outputPath,
outRootPath: __dirname,
}
);
const outputCodeWithConfig = t(
{
source: code.toString(),
path: inputPath
},
{
gogocode: $
},
{
rootPath: __dirname,
outFilePath: outputPath,
outRootPath: __dirname,
prettierrc: "./prettierrc.json"
}
);
fs.writeFileSync(outputPath, outputCode, { encoding: "utf-8" });
fs.writeFileSync(outputPathWithConfig, outputCodeWithConfig, { encoding: "utf-8" });
console.log('The file was saved!');
});