Metalsmith.js: How do I create the same directory as the build script?
I am completely new to metalmith. I am following this tutorial: http://www.robinthrift.com/post/metalsmith-part-1-setting-up-the-forge/
I want to create my site in the root directory of my project (same directory as the build script). I want to do this because I want the github pages to play well with it. But when I try to build I get this error: Error: EBUSY, busy or blocked resource
Here is my structure:
- project_folder /
- _site-Src /
- index.html
- node_modules
- build.js
- package.json
- _site-Src /
Here is my build.js source:
var Metalsmith = require("metalsmith");
Metalsmith(__dirname)
.source("_site_src")
.destination(".")
.build();
I want my project dir to look like this:
- project_folder /
- _site-Src /
- index.html
- node_modules
- build.js
- package.json
- index.html
- _site-Src /
I don't know what I am doing wrong. I appreciate any help.
source to share
Error message:
Error: EBUSY, busy or blocked resource
seems to be a file lock / usage bug. (I'm not familiar with Node.js bugs)
I would guess that this happens when Metalsmith tries to clear the build folder (this is your solution folder, which is a very bad idea). This is enabled by default, but can be disabled.
To disable this use:
.clean(false)
before creating.
BUT if you remove items from the original folder, they will not be removed from your build folder. You might be able to handle this with a custom script cleaner or plugin.
I have no experience with github pages, but I think it's best to avoid the problem.
You could add a symbolic link to the build folder from the project folder for the file index.html
.
source to share