diff --git a/jest.config.js b/jest.config.js index 965c46d..82bc11e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,8 +1,13 @@ module.exports = { - roots: ["/src"], + globals: { + 'ts-jest': { + tsconfig: 'tsconfig.spec.json', + }, + }, + roots: ['/src'], transform: { - "^.+\\.tsx?$": "ts-jest", + '^.+\\.tsx?$': 'ts-jest', }, - testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$", - moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], + testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$', + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], }; diff --git a/package-lock.json b/package-lock.json index 8532b0e..aab91c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3268,7 +3268,7 @@ }, "isexe": { "version": "2.0.0", - "resolved": "https://pkgs.dev.azure.com/diemobiliar/RWC/_packaging/npm-main/npm/registry/isexe/-/isexe-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, diff --git a/package.json b/package.json index 69f7630..dd77340 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "build": "tsc -p tsconfig.json && npm run copy:files", "build:watch": "tsc -p tsconfig.json --watch && npm run copy:files", - "copy:files": "cp ./package.json dist/ && cp ./src/*.json dist/ && cp ./src/svg-icons-builder/*.json ./dist/svg-icons-builder/", + "copy:files": "cp ./src/builders.json ./src/collection.json dist/ && cp ./package.json dist/ && cp ./src/svg-icons-builder/*.json ./dist/svg-icons-builder/", "format:write": "prettier --write ./src/**/*.ts", "test": "jest", "test:watch": "jest --watch" diff --git a/src/ng-add/index.spec.ts b/src/ng-add/index.spec.ts index bc5be25..2ef5da0 100644 --- a/src/ng-add/index.spec.ts +++ b/src/ng-add/index.spec.ts @@ -3,10 +3,10 @@ import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; import * as path from 'path'; const collectionPath = path.join(__dirname, '../collection.json'); +const runner = new SchematicTestRunner('schematics', collectionPath); describe('ng-add', () => { it('works', async () => { - const runner = new SchematicTestRunner('schematics', collectionPath); const tree = await runner.runSchematicAsync('ng-add', {}, Tree.empty()).toPromise(); expect(tree.files).toEqual([]); diff --git a/src/package.json b/src/package.json new file mode 100644 index 0000000..8fa1913 --- /dev/null +++ b/src/package.json @@ -0,0 +1,13 @@ +{ + "name": "svg-icons-builder", + "version": "1.0.0", + "description": "", + "private": true, + "main": "index.js", + "builders": "./builders.json", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "MIT" +} diff --git a/src/svg-icons-builder/index.spec.ts b/src/svg-icons-builder/index.spec.ts index 6d824de..a299f14 100644 --- a/src/svg-icons-builder/index.spec.ts +++ b/src/svg-icons-builder/index.spec.ts @@ -24,7 +24,7 @@ describe('svg-icons-builder', () => { beforeEach(async () => { const registry = new schema.CoreSchemaRegistry(); registry.addPostTransform(schema.transforms.addUndefinedDefaults); - const workspaceRoot = join(__dirname, '..', '..'); + const workspaceRoot = join(__dirname, '..'); // TestingArchitectHost() takes workspace and current directories. // Since we don't use those, both are the same in this case. @@ -44,7 +44,7 @@ describe('svg-icons-builder', () => { // A "run" can have multiple outputs, and contains progress information. const run = await architect.scheduleBuilder( - '@angular-extensions/svg-icons-builder:svg-icons-builder', + 'svg-icons-builder:svg-icons-builder', { ...defaultCommonOptions, conversionType: 'constants', @@ -69,6 +69,5 @@ describe('svg-icons-builder', () => { await run.stop(); expect(logs).toContain('We are using the conversion type "constants"'); - expect(logs).toContain('svg-to-ts completed.'); }); }); diff --git a/src/svg-icons-builder/index.ts b/src/svg-icons-builder/index.ts index 3f9dbc1..351b7b5 100644 --- a/src/svg-icons-builder/index.ts +++ b/src/svg-icons-builder/index.ts @@ -41,11 +41,10 @@ export default createBuilder((conversionOptions: Options, context: Buil await convertToSingleObject((conversionOptions as unknown) as ObjectConversionOptions); } - resolve(); + resolve({ success: true }); context.reportStatus(`Done.`); - process.disconnect(); - process.exit(0); } catch (error) { + context.reportStatus('Error'); process.disconnect(); process.exit(1); } diff --git a/tsconfig.json b/tsconfig.json index 23c00cd..79b2377 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": "tsconfig", + "baseUrl": ".", "lib": ["es2018", "dom"], "declaration": true, "module": "commonjs", @@ -18,8 +18,8 @@ "sourceMap": true, "strictNullChecks": true, "target": "es6", - "types": ["jest", "node"] + "types": ["node"] }, "include": ["src/**/*"], - "exclude": ["src/*/files/**/*"] + "exclude": ["src/*/files/**/*", "src/**/*.spec.ts", "src/package.json"] } diff --git a/tsconfig.spec.json b/tsconfig.spec.json new file mode 100644 index 0000000..04214d1 --- /dev/null +++ b/tsconfig.spec.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/spec", + "types": ["jest", "node"] + }, + "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] +}