Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generators/app/templates/ext-command-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"sourceMap": true,
"rootDir": "src",
"strict": true /* enable all strict type-checking options */
"strict": true, /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"sourceMap": true,
"rootDir": "src",
"strict": true /* enable all strict type-checking options */
"strict": true, /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"sourceMap": true,
"rootDir": "src",
"strict": true /* enable all strict type-checking options */
"strict": true, /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/ext-command-web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"sourceMap": true,
"rootDir": "src",
"strict": true /* enable all strict type-checking options */
"strict": true, /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"types": ["node"],
"sourceMap": true,
"strict": true /* enable all strict type-checking options */
"strict": true, /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@types/node": "^18.19.57",
"mocha": "^10.7.3",
"yeoman-environment": "^4.4.3",
"yeoman-test": "^10.0.1"
"yeoman-test": "^10.0.1",
"jsonc-parser": "^3.3.1"
}
}
40 changes: 5 additions & 35 deletions test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,9 @@

import * as path from 'path';
import { fileURLToPath } from 'url';
import { RunResult, createHelpers } from 'yeoman-test';
import { createHelpers } from 'yeoman-test';
import { parse } from 'jsonc-parser';
import * as env from '../generators/app/env.js';
import { cwd } from 'process';

function stripComments(content) {
/**
* First capturing group matches double quoted string
* Second matches single quotes string
* Third matches block comments
* Fourth matches line comments
*/
const regexp = /("(?:[^\\\"]*(?:\\.)?)*")|('(?:[^\\\']*(?:\\.)?)*')|(\/\*(?:\r?\n|.)*?\*\/)|(\/{2,}.*?(?:(?:\r?\n)|$))/g;
const result = content.replace(regexp, (match, m1, m2, m3, m4) => {
// Only one of m1, m2, m3, m4 matches
if (m3) {
// A block comment. Replace with nothing
return '';
} else if (m4) {
// A line comment. If it ends in \r?\n then keep it.
const length = m4.length;
if (length > 2 && m4[length - 1] === '\n') {
return m4[length - 2] === '\r' ? '\r\n' : '\n';
} else {
return '';
}
} else {
// We match a string
return match;
}
});
return result;
}


describe('test code generator', function () {
this.timeout(10000);
Expand Down Expand Up @@ -753,7 +723,7 @@ describe('test code generator', function () {

runResult.assertJsonFileContent('testCom/package.json', expectedPackageJSON);

const tsconfigBody = JSON.parse(stripComments(runResult.fs.read('testCom/tsconfig.json')));
const tsconfigBody = parse(runResult.fs.read('testCom/tsconfig.json'));
runResult.assertObjectContent(tsconfigBody, expectedTsConfig);
} finally {
cleanup(runResult);
Expand Down Expand Up @@ -833,7 +803,7 @@ describe('test code generator', function () {

runResult.assertJsonFileContent('testCom/package.json', expectedPackageJSON);

const tsconfigBody = JSON.parse(stripComments(runResult.fs.read('testCom/tsconfig.json')));
const tsconfigBody = parse(runResult.fs.read('testCom/tsconfig.json'));
runResult.assertObjectContent(tsconfigBody, expectedTsConfig);
} finally {
cleanup(runResult);
Expand Down Expand Up @@ -1196,7 +1166,7 @@ describe('test code generator', function () {
]
};

const jsconfigBody = JSON.parse(stripComments(runResult.fs.read('testCom/jsconfig.json')));
const jsconfigBody = parse(runResult.fs.read('testCom/jsconfig.json'));
runResult.assertObjectContent(jsconfigBody, expectedJSConfig);
} finally {
cleanup(runResult);
Expand Down
Loading