ng-filename-parser
TypeScript icon, indicating that this package has built-in type declarations

2.2.1 • Public • Published

ng filename parser

Angular file name convention parser

src/                                    project source code
|- app/
|  |- user/                             user module
|  |- components/                       dummy components
|  |  |- menu/
|  |  |  |- menu.component.html
|  |  |  |- menu.component.scss
|  |  |  |- menu.component.spec.ts
|  |  |  |- menu.component.ts
|  |  |  |- menu.stories.ts
|  |- pages/                            smart components
|  |  |- dashboard/
|  |  |  |- dashboard.page.html
|  |  |  |- dashboard.page.scss
|  |  |  |- dashboard.page.spec.ts
|  |  |  |- dashboard.page.stories.ts   also support dashboard.stories.ts
|  |  |  |- dashboard.page.ts
|  +- ...

Installation

npm install --save ng-filename-parser

Usage

Import required helper function.

import {
  getNgFilenameTokens,
  getStyleFile,
  getHtmlFile,
  getSpecFile,
  getTypescriptFile,
  getStorybookFile,
} from 'ng-filename-parser'

getNgFilenameTokens

Pass as argument the angular project filename to tokenizer to getNgFilenameTokens

const filename = '/home/angular/project/src/app/app.component.ts'
const tokens = getNgFilenameTokens(filename)

This will return:

{
  component: 'app',
  type: ['component']
}

getFiles functions

Based on filename tokens user could request filename of styles/ts/stories/spec files.

  • getStyleFile
  • getHtmlFile
  • getSpecFile
  • getTypescriptFile
  • getStorybookFile

Checkout testing files for more information.

Release

  • run npm run release

License

Luis Reinoso 2021 MIT License

Readme

Keywords

Package Sidebar

Install

npm i ng-filename-parser

Weekly Downloads

1

Version

2.2.1

License

MIT

Unpacked Size

26.3 kB

Total Files

11

Last publish

Collaborators

  • luis.reinoso