summaryrefslogtreecommitdiff
path: root/systrace/catapult/common/node_runner/node_runner/minifyjs
blob: e5941697064f71668e23b66e8f7fe70ce5451ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env node
'use strict';
/*
Copyright 2019 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.

This script strips whitespace and comments from Javascript.
*/
const escodegen = require('escodegen');
const espree = require('espree');
const fs = require('fs');
const nopt = require('nopt');

const args = nopt();
const filename = args.argv.remain[0];

let text = fs.readFileSync(filename).toString('utf8');
const ast = espree.parse(text, {ecmaVersion: 2018});
text = escodegen.generate(ast, {format: {indent: {style: ''}}});
fs.writeFileSync(filename, text);