-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(svg-generator): support special file name cases (#137)
- Loading branch information
1 parent
1314a49
commit f4d26b0
Showing
16 changed files
with
6,385 additions
and
3,690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: '@ngneat/svg-icon' | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
cache: 'npm' | ||
|
||
- name: Install dependencies | ||
run: npm i | ||
|
||
- name: Run Build | ||
run: npm run build:lib | ||
|
||
- name: Run unit tests | ||
run: npm run test:lib:headless | ||
env: | ||
CI: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,3 @@ testem.log | |
.DS_Store | ||
Thumbs.db | ||
node_modules | ||
*.js |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {resolveIdentifierName} from "../tree"; | ||
import {defaultConfig, GeneratorConfig} from "../config"; | ||
|
||
type InvalidName = string; | ||
type Expected = string; | ||
|
||
describe('resolveIdentifierName', () => { | ||
const invalidNames: Array<[InvalidName, Expected]> = [ | ||
['1inch', `$inch`], | ||
['sth.b', `sthB`], | ||
['st_b_', `stB`], | ||
['some-n#me', `someN$me`], | ||
['_some', `some`], | ||
]; | ||
|
||
it('should normalize the icon name', () => { | ||
for (const item of invalidNames) { | ||
assertName(item, defaultConfig); | ||
} | ||
}); | ||
|
||
it('should be configurable', () => { | ||
const customConfig = { | ||
...defaultConfig, | ||
invalidCharReplacer: () => '$$' | ||
} | ||
assertName(['1inch', `$$inch`], customConfig) | ||
}); | ||
|
||
}); | ||
|
||
function assertName([name, expected]: [InvalidName, Expected], config: Required<GeneratorConfig>) { | ||
expect(resolveIdentifierName(name, config)).toEqual(`${expected}${config.postfix}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
export interface Config { | ||
export interface GeneratorConfig { | ||
srcPath: string; | ||
outputPath: string; | ||
svgoConfig: { plugins: any[] }; | ||
prefix?: string; | ||
postfix?: string; | ||
rootBarrelFile?: boolean; | ||
rootBarrelFileName?: string; | ||
invalidCharReplacer?: (invalidChar: string) => string; | ||
} | ||
|
||
export const defaults: Config = { | ||
export const defaultConfig: Required<GeneratorConfig> = { | ||
prefix: '', | ||
postfix: 'Icon', | ||
svgoConfig: { plugins: [] }, | ||
srcPath: '', | ||
outputPath: '', | ||
rootBarrelFile: false, | ||
rootBarrelFileName: 'index', | ||
invalidCharReplacer: () => '$' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
modulePathIgnorePatterns: ['<rootDir>/dist'], | ||
}; |
Oops, something went wrong.