build: don't use deprecated $(location) pre-declared variable (#36308)

$(location) is not recommended in the bazel docs as depending on context it will either return the value of $(execpath) or $(rootpath). rules_nodejs now supports $(rootpath) and $(execpath) in templated_args of nodejs_binary.

PR Close #36308
This commit is contained in:
Greg Magolan
2020-03-29 13:29:50 -07:00
committed by Alex Rickabaugh
parent 61e5ab4703
commit c58e6ba13a
8 changed files with 16 additions and 14 deletions

View File

@ -9,6 +9,8 @@
import * as fs from 'fs';
import {SymbolExtractor} from './symbol_extractor';
const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER'] as string);
if (require.main === module) {
const args = process.argv.slice(2) as[string, string];
process.exitCode = main(args) ? 0 : 1;
@ -22,8 +24,8 @@ if (require.main === module) {
* ```
*/
function main(argv: [string, string, string] | [string, string]): boolean {
const javascriptFilePath = require.resolve(argv[0]);
const goldenFilePath = require.resolve(argv[1]);
const javascriptFilePath = runfiles.resolveWorkspaceRelative(argv[0]);
const goldenFilePath = runfiles.resolveWorkspaceRelative(argv[1]);
const doUpdate = argv[2] == '--accept';
const javascriptContent = fs.readFileSync(javascriptFilePath).toString();