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

Multiple metalsmith-changed-ctimes.json generated #11

Closed
oscarotero opened this issue Sep 17, 2016 · 9 comments
Closed

Multiple metalsmith-changed-ctimes.json generated #11

oscarotero opened this issue Sep 17, 2016 · 9 comments

Comments

@oscarotero
Copy link

Hello.
In my installation, metalsmith creates some subdirectories in my build folder and a metalsmith-changed-ctimes.json is created for each subdirectory. For example:

build
  |_ slug-1
      |_ index.html
      |_ metalsmith-changed-ctimes.json
  |_ slug-2
      |_ index.html
      |_ metalsmith-changed-ctimes.json
  |_ index.html
  |_ metalsmith-changed-ctimes.json

I use also browsersync to watch and livereload changes, and rsync to upload the site. So, the placement of this file in the build folder requires to configure these tools to ignore these file.
I suggest to allow to configure where the file is saved, for example:

changed({
    ctimesFile: __dirname + '/tmp'
});
@arve0
Copy link
Owner

arve0 commented Sep 17, 2016

Hm, that is strange. It should not do that. Can you create an example to reproduce?

Also, this option already exists, but it's not documented. You can use it like this:

.use(changed({ ctimes: 'path/to/ctimes.json' })

@oscarotero
Copy link
Author

This is my configuration:

const metalsmith = require('metalsmith'),
      path       = require('path'),
      changed    = require('metalsmith-changed'),
      markdown   = require('metalsmith-markdown'),
      layouts    = require('metalsmith-layouts'),
      permalinks = require('metalsmith-permalinks'),
      handlebars = require('handlebars'),
      config     = require('../config'),

metalsmith(config.paths.root)
  .metadata(config.metadata || {})
  .source(path.join(config.paths.src, config.paths.data))
  .destination(config.paths.build)
  .clean(false)
  .use(changed())
  .use(markdown())
  .use(permalinks())
  .use(layouts({
    engine: 'handlebars',
    directory: path.join(config.paths.src, config.paths.layouts),
    partials: path.join(config.paths.src, paths.partials),
    exposeConsolidate: function (requires) {
      requires.handlebars = handlebars;
    }
  }))
  .build(function(err, files) {
    if (err) {
      console.error(err);
    }
});

And yes, I had noticed the ctimes option but it's relative to the destination path.

So, after change the options to this:

.use(changed({
      ctimes: path.join(paths.root, 'tmp/metalsmith-changed-ctimes.json')
}))

I have now the file correctly created but other subfolders /sites/example.com/www/tmp/metalsmith-changed-ctimes.json created in each folder of the build path

@arve0
Copy link
Owner

arve0 commented Sep 17, 2016

I had to simplify your setup, as I do not have your templates:

const metalsmith = require('metalsmith'),
      changed    = require('metalsmith-changed'),
      markdown   = require('metalsmith-markdown'),
      permalinks = require('metalsmith-permalinks'),
      handlebars = require('handlebars');

metalsmith(__dirname)
  .clean(false)
  .use(changed())
  .use(markdown())
  .use(permalinks())
  .build(function(err, files) {
    if (err) {
      console.error(err);
    }
});

It does not reproduce the error described:

mkdir changed_err
cd changed_err/
npm init --yes
npm i -S metalsmith metalsmith-changed metalsmith-markdown metalsmith-layouts metalsmith-permalinks handlebars
mkdir src
echo -e "---\ntitle: index\n---\n\ncontent" > src/index.md
mkdir -p src/asdf
echo -e "---\ntitle: index\n---\n\ncontent" > src/asdf/index.md
node index.js
find build

output

build/
build/asdf
build/asdf/index.html
build/index.html
build/metalsmith-changed-ctimes.json

@arve0
Copy link
Owner

arve0 commented Sep 17, 2016

Anyhow, you can debug this yourself:

  1. In node_modules/metalsmith-changed/index.js put debugger; in this line.
  2. Run your build file with node debug build_file.js.
  3. Press c for continue.
  4. Will stop at the debugger line.
  5. Use REPL or go to step 3.

Happy to debug if you could supply me with a working demo of the issue.

@arve0
Copy link
Owner

arve0 commented Sep 17, 2016

Do you use gulp or similar to feed Metalsmith with files upon file changes?

@oscarotero
Copy link
Author

Yes I use gulp.
I've created a new brach in this project: https://github.com/oscarotero/oscarotero.com/tree/metalsmith-changed
The task is html

On execute gulp html, I have a lot of metalsmith-changed-ctimes.json files.

@oscarotero
Copy link
Author

You have to use the metalsmith-changed branch

El 17 sept 2016, a las 17:23, Arve Seljebu notifications@github.com escribió:

Still unable to reproduce:

git clone https://github.com/oscarotero/oscarotero.com
cd oscarotero.com/
npm i
gulp
find build/
output

build/
build/css
build/css/styles.css
build/en
build/en/index.html
build/es
build/es/index.html
build/gl
build/gl/index.html
build/img
build/img/favicon.png
build/img/image.jpg
build/index.html
build/js
build/js/main.js

You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #11 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AAXEEZtTvVZcalLWDgypKLBGuoCnE2Alks5qrAXwgaJpZM4J_leO.

@arve0
Copy link
Owner

arve0 commented Sep 17, 2016

It's an issue with permalinks:

    .use(markdown())
    // .use(permalinks())
    .use(layouts({

output

build
build/en.html
build/es.html
build/gl.html
build/index.html
build/metalsmith-changed-ctimes.json

@arve0 arve0 closed this as completed Sep 17, 2016
@oscarotero
Copy link
Author

Ok, sorry and thank you!!

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

2 participants