Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

fs createReadStream pipe to createWriteStream #8270

Closed
cloudcome opened this issue Aug 27, 2014 · 4 comments
Closed

fs createReadStream pipe to createWriteStream #8270

cloudcome opened this issue Aug 27, 2014 · 4 comments

Comments

@cloudcome
Copy link

fs.createReadStream('../src/1.html').pipe(fs.createWriteStream('../dest/1.html'));
fs.createReadStream('../src/1.css').pipe(fs.createWriteStream('../dest/1.css'));
fs.createReadStream('../src/a.js').pipe(fs.createWriteStream('../dest/a.js'));

ret
ONLY ../dest/1.html is EMPTY

@danyshaanan
Copy link

Check this out:

This is my setup:

var fs = require('fs')
fs.mkdirSync('src')
fs.mkdirSync('dest')
fs.writeFileSync('./src/1.html','<html></html>')
fs.writeFileSync('./src/1.css','body {background-color:#f00}')
fs.writeFileSync('./src/a.js','"use strict"\n\nvar a = 0;')

Then I run this:

var fs = require('fs')
fs.createReadStream('./src/1.html').pipe(fs.createWriteStream('./dest/1.html'));
fs.createReadStream('./src/1.css').pipe(fs.createWriteStream('./dest/1.css'));
fs.createReadStream('./src/a.js').pipe(fs.createWriteStream('./dest/a.js'));

and all files are copied as expected, and regarding this: jprichardson/node-fs-extra#79 , the same code works the same with fs-extra, (with the code above or with require('fs-extra').copy('./src', './dest')).

@danyshaanan
Copy link

...the best thing would be to push a repo with the exact files the code you're running so that we could reproduce it. Also, include node version and the fs/fs-extra versions you're using.

@cloudcome
Copy link
Author

该文件(1.html)内容应该在缓存中,表面上还是有内容的,但实际内容已经为空了。当我关闭编辑器重新打开后,再次运行就得到正确的结果了。
你的建议已收到。
^_^

@danyshaanan
Copy link

Google translate:

The file (1.html) content should be in the cache, on the surface or with the content, but the actual content is already empty. When I close the editor re-open and run it again to get the correct result.
Your suggestion has been received.
^ _ ^

Sounds like it's a problem with your editor, like it's not watching the file changes.

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

No branches or pull requests

2 participants