bencoveney / barrelsby

Automatic TypeScript barrels (index.ts files) for your entire code base

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Barrels files updated with wrong content on repetitive run if `noHeader` flag enabled

aborovsky opened this issue · comments

Description
Barrels were generated already with the noHeader flag enabled.
When one will rerun barrelsby with delete flag enabled, barrels files are not deleted and moreover: will be reused.
As a result, each barrel file will be updated with content:

export * from './index';

To Reproduce
Steps to reproduce the behavior:

  1. SetupTS project with package.json dependency: "barrelsby": "2.5.1"
  • mkdir barreslsby-issue
  • cd barreslsby-issue
  • npm init (just accept default values)
  • npm i barrelsby@2.5.1 --save-exact
  • npm i typescript
  • add tsconfig.json at the project's root:
{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "skipLibCheck": true
  },
  "include": ["src"]                
}
  • mkdir -p src/directory1
  • touch ./src/directory1/example.ts
  1. Add .barrelsby.json configuration file at the project's root:
{
  "directory": [
    "./src/directory1",
    "./src"
  ],
  "noHeader": true,
  "delete": true
}
  1. Run local barrelsby with command: ./node_modules/.bin/barrelsby -V --config .barrelsby.json
  2. Check proper content for 2 generated files:
  • cat ./src/index.ts, gives: export * from "./directory1/index";
  • cat ./src/directory1/index.ts, gives: export * from "./example";
  1. Rerun barrelsby with same command: ./node_modules/.bin/barrelsby -V --config .barrelsby.json
  2. Check wrong content for 2 updated files:
  • cat ./src/index.ts, gives: export * from "./index";
  • cat ./src/directory1/index.ts, gives: export * from "./index";

Expected behavior
When noHeader flag enabled, barrelsby should delete barrels found even if it has no autogenerated header inside.

Environment:

Additional context
Relates to: #153 (comment)