Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming files with "gulp-rename" in "registerTransformStream" causes "Error: write after end" #577

Closed
asmagin opened this issue May 21, 2018 · 6 comments

Comments

@asmagin
Copy link

asmagin commented May 21, 2018

Type of issue

Bug

My environment

  • OS version/details: Windows 10 64-bit
  • Node version: v8.11.2
  • npm version: 6.0.1
  • Version of yo : 2.0.2

Expected behavior

Rename of a file in registerTransformStream doesn't cause errors.

Current behavior

when I'm trying to rename a file with gulp-rename in registerTransformStream I see an error after the write method execution.

Steps to reproduce the behavior

  self.registerTransformStream(
    rename(function (path) {
      path.basename = path.basename.replace(/(SolutionX)/g, self.options.solutionName)
      path.dirname = path.dirname.replace(/(SolutionX)/g, self.options.solutionName)
    })
  );

Command line output

  yeoman:generator Running writing +0ms
{ dot: true,
  sync: true,
  debug: true,
  ignore:
   [ '**/code/bin/**/*.*',
     '**/code/obj/**/*.*',
     '**/*.user',
     '**/src/packages/**/*',
     '**/src/node_modules/**/*',
     '**/.vs*/**/*' ] }
Old:    package.json
   create package.json
Old:    .prettierrc
   create .prettierrc
Old:    build.cake
   create build.cake
Old:    build.ps1
   create build.ps1
Old:    LICENSE
   create LICENSE
Old:    publishsettings.targets
   create publishsettings.targets
Old:    readme.md
   create readme.md
Old:    Settings.StyleCop
   create Settings.StyleCop
Old:    SolutionX.sln     # << ------ original file
   create MySolution.sln  # << ------ renamed file
Old:    tsconfig.json
   create tsconfig.json
Old:    tslint.json
   create tslint.json
Old:    webpack.config.js
   create webpack.config.js
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: write after end
    at writeAfterEnd (_stream_writable.js:236:12)
    at Transform.Writable.write (_stream_writable.js:287:5)
    at DestroyableTransform.ondata (D:\.projects\my-generator\scaffold\node_modules\readable-stream\lib\_stream_readable.js:619:20)
    at emitOne (events.js:116:13)
    at DestroyableTransform.emit (events.js:211:7)
    at addChunk (D:\.projects\my-generator\scaffold\node_modules\readable-stream\lib\_stream_readable.js:291:12)
    at readableAddChunk (D:\.projects\my-generator\scaffold\node_modules\readable-stream\lib\_stream_readable.js:278:11)
    at DestroyableTransform.Readable.push (D:\.projects\my-generator\scaffold\node_modules\readable-stream\lib\_stream_readable.js:245:10)
    at DestroyableTransform.Transform.push (D:\.projects\my-generator\scaffold\node_modules\readable-stream\lib\_stream_transform.js:148:32)
    at DestroyableTransform._transform (D:\.projects\my-generator\scaffold\node_modules\mem-fs-editor\lib\actions\commit.js:34:12)
    at DestroyableTransform.Transform._read (D:\.projects\my-generator\scaffold\node_modules\readable-stream\lib\_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (D:\.projects\my-generator\scaffold\node_modules\readable-stream\lib\_stream_transform.js:172:83)
    at doWrite (D:\.projects\my-generator\scaffold\node_modules\readable-stream\lib\_stream_writable.js:428:64)
    at writeOrBuffer (D:\.projects\my-generator\scaffold\node_modules\readable-stream\lib\_stream_writable.js:417:5)
    at DestroyableTransform.Writable.write (D:\.projects\my-generator\scaffold\node_modules\readable-stream\lib\_stream_writable.js:334:11)
    at DestroyableTransform.ondata (C:\Users\asmagin\AppData\Roaming\npm\node_modules\yo\node_modules\readable-stream\lib\_stream_readable.js:619:20)
@asmagin asmagin changed the title Renaming files with "gulp-rename" in "registerTransformStream" causes Renaming files with "gulp-rename" in "registerTransformStream" causes "Error: write after end" May 21, 2018
@UncleWalt
Copy link

This seems to be caused by recent changes in gulp-rename (current version 1.2.3). Older versions work just fine. In my case i had to pin gulp-rename to 1.2.2 to fix my generators.

@SBoudrias
Copy link
Member

Thanks @UncleWalt, I'll close this issue then.

@afeiship
Copy link

@UncleWalt thanks, it works.

@asmagin
Copy link
Author

asmagin commented May 29, 2018

I tried registerTransformStream without gulp-rename, providing custom transform stream and it produces the same error.

dmborel pushed a commit to dmborel/Sitecore-EngX-Scaffold that referenced this issue Sep 7, 2018
Toilal added a commit to inetum-orleans/generator-docker-devbox that referenced this issue Oct 24, 2018
@Toilal
Copy link

Toilal commented Oct 24, 2018

This is still an issue with gulp-rename 1.4.0

rohit-gohri added a commit to danger/generator-danger-plugin that referenced this issue Feb 15, 2020
orta pushed a commit to danger/generator-danger-plugin that referenced this issue Feb 16, 2020
* fix(build): update typescript dep and add @types/node

Updated typescript to v3.x, and add node types to fix tsc build

Closes #25

* build(dependencies): update dev dependencies and related configs

re #25

* improvement: update dev dependencies and related configs in default template

* fix: fix tooling configs not in default

* build: remove typescript (not needed) and add semantic release script

* build: update babel and babelrc

* test: ignore built and template tests

* chore: Update yeoman dependencies and lock gulp-rename

yeoman relevant issue: yeoman/yo#577
gulp-rename: relevant issue: hparra/gulp-rename#84

* test: update snapshots

* ci: Test on modern nodejs version

* chore: Update vscode jest debug config

* ci: use yarn in travis ci

* fix: downgrade commitzen, didn't work with node<=10

* refactor: remove node<10 support

BREAKING CHANGE: Removed support for node<10 in the generator and the generated plugins too

* fix: update babel config and dependencies in template
@xenogenesi
Copy link

Still an issue with gulp-rename 2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants