admin管理员组文章数量:1336632
I am trying to copy the content from one file to another. I am trying the following code but its throwing me an error.
gulp
.src('core/core.config.local.tpl.js')
.pipe(gulp.dest(core/core.config.js));
Error: EEXIST: file already exists, mkdir 'C:\Users\krish\Documents\test\app\core\core.config.js' at Error (native)
Is there any other process that I could use to copy content?
I am trying to copy the content from one file to another. I am trying the following code but its throwing me an error.
gulp
.src('core/core.config.local.tpl.js')
.pipe(gulp.dest(core/core.config.js));
Error: EEXIST: file already exists, mkdir 'C:\Users\krish\Documents\test\app\core\core.config.js' at Error (native)
Is there any other process that I could use to copy content?
Share Improve this question asked Feb 27, 2016 at 14:43 KrishhKrishh 4,2316 gold badges43 silver badges52 bronze badges2 Answers
Reset to default 8gulp.dest
expects a directory as an argument. All files are written to this destination directory. If the directory doesn't exist yet, gulp tries to create it.
In your case gulp.dest
tries to create a directory core/core.config.js
, but fails since a regular file with the same name already exists.
If your goal is to have the regular file at core/core.config.js
be overwritten with the contents of core/core.config.local.tpl.js
on every build, you can do it like this:
var gulp = require('gulp');
var rename = require('gulp-rename');
gulp.task('default', function() {
gulp.src('core/core.config.local.tpl.js')
.pipe(rename({ basename: 'core.config'}))
.pipe(gulp.dest('core'));
});
I think you were missing the quotes only when entering the the question here, right?
gulp.dest()
expects a folder to copy all the files in the stream, so you cannot use a single file name here (As the error says: "mkdir failed"). See: https://github./gulpjs/gulp/blob/master/docs/API.md#gulpdestpath-options
When you do your gulp.src()
you can set a base path to build the relative path from and so gulp can copy your single file to the given output folder. See: https://github./gulpjs/gulp/blob/master/docs/API.md#optionsbase
As you also want to rename the file, you need something like gulp-rename: https://www.npmjs./package/gulp-rename
本文标签: javascriptGulp Copy content from one file to another fileStack Overflow
版权声明:本文标题:javascript - Gulp Copy content from one file to another file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742414573a2470463.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论