Skip to content

Commit 7581398

Browse files
committed
Fix the new Runner
1 parent 5f6e8ad commit 7581398

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

bin/cli.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/usr/bin/env node
22
'use strict';
33

4-
const Runner = require('../transforms/no-implicit-this/helpers/runner');
4+
const Runner = require('../transforms/no-implicit-this/helpers/runner').default;
55

6-
Runner.withArgs(process.argv.slice(2))
7-
.run()
6+
const args = process.argv.slice(2);
7+
8+
Runner.withArgs(args)
9+
.run(__dirname, args)
810
.catch((error) => {
911
console.error(error);
1012
process.exit(1);

test/fixtures/3.28/input/app/components/gherkyn.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{! template-lint-disable no-implicit-this }}
22
{{! template-lint-disable no-curly-component-invocation }}
3-
<h1>[{{this.property}}]</h1>
3+
<h1>[{{property}}]</h1>
44

55
<h1>[{{this.property}}]</h1>
66

test/fixtures/3.28/output/app/components/.gitkeep

Whitespace-only changes.

test/helpers/test-runner.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@ export class TestRunner {
2727
}
2828

2929
async runCodemodRuntime() {
30-
await execa(
31-
'../../../../bin/cli.js',
32-
['http://localhost:4200', 'app', '--telemetry=runtime'],
33-
this.execOpts
34-
);
30+
await execa('../../../../bin/cli.js', ['--root=app', '--telemetry=runtime'], this.execOpts);
3531
}
3632

3733
async runCodemodEmbroider() {
38-
await execa('../../../../bin/cli.js', ['app', '--telemetry=embroider'], this.execOpts);
34+
await execa('../../../../bin/cli.js', ['--root=app', '--telemetry=embroider'], this.execOpts);
3935
}
4036

4137
async runEmbroiderStage2Build(): Promise<void> {

transforms/no-implicit-this/helpers/runner.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ import { assert, isRecord } from '../../../helpers/types';
1313
const debug = Debug('ember-no-implicit-this-codemod');
1414

1515
export interface Options {
16+
root: string;
1617
config: string | undefined;
1718
telemetry: 'auto' | 'embroider' | 'runtime';
1819
url: string;
1920
}
2021

2122
export const Parser = yargs
23+
.option('root', {
24+
describe: 'app root FIXME',
25+
default: 'app',
26+
normalize: true,
27+
})
2228
.option('config', {
2329
describe: 'Path to config file FIXME',
2430
normalize: true,
@@ -64,6 +70,7 @@ export default class Runner {
6470

6571
static withOptions(options: Partial<Options> = {}): Runner {
6672
return new Runner({
73+
root: 'app',
6774
config: undefined,
6875
telemetry: 'auto',
6976
url: 'http://localhost:4200',
@@ -113,7 +120,7 @@ export default class Runner {
113120
}
114121
}
115122

116-
async run(): Promise<void> {
123+
async run(root: string, args: string[]): Promise<void> {
117124
const telemetryType = await this.detectTelemetryType();
118125

119126
if (telemetryType === 'runtime') {
@@ -124,7 +131,7 @@ export default class Runner {
124131
debug('Gathered telemetry on %d modules', Object.keys(telemetry).length);
125132
}
126133

127-
runTransform(__dirname, 'no-implicit-this', process.argv, 'hbs');
134+
runTransform(root, 'no-implicit-this', [this.options.root, ...args], 'hbs');
128135
}
129136

130137
private async detect(): Promise<DetectResult> {

0 commit comments

Comments
 (0)