metalsmith-sass icon indicating copy to clipboard operation
metalsmith-sass copied to clipboard

Doesn't seem to play nice with `gulp-metalsmith`

Open justinhelmer opened this issue 8 years ago • 2 comments

First, thanks for building a much-needed libSass wrapper for metalsmith.

Unfortunately, I am having an issue getting it set up.

I haven't had an opportunity to dig in, but gulp-metalsmith seems to work with every other plugin I have tried.

With metalsmith-sass, there is an error:

Message:
    Arguments to path.join must be strings
Stack:
TypeError: Arguments to path.join must be strings
    at Object.posix.join (path.js:488:13)
    at compileSass (/Users/justin/workspace/gh-release-manager/node_modules/metalsmith-sass/lib/index.js:121:33)
    at Ware.<anonymous> (/Users/justin/workspace/gh-release-manager/node_modules/wrap-fn/index.js:45:19)
    at next (/Users/justin/workspace/gh-release-manager/node_modules/ware/lib/index.js:85:20)
    at Ware.run (/Users/justin/workspace/gh-release-manager/node_modules/ware/lib/index.js:88:3)
    at Object.run (/Users/justin/workspace/gh-release-manager/node_modules/gulp-metalsmith/lib/metalsmith.js:25:36)

This appears to be the context (lib/index.js:111):

/**
 * Looks up different key names on `metalsmith` to support
 * old versions (< v1) of Metalsmith. At some point, I will remove
 * support for < v1 and remove the key lookups
 */
var directory = metalsmith.dir || metalsmith._directory,
    source = metalsmith._src || metalsmith._source,
    basePath = path.join(directory, source);

Both directory and source end up being null. Any help would be greatly appreciated.

justinhelmer avatar Feb 06 '16 23:02 justinhelmer

Oh strange, I haven't heard any other issues with it before.

Can you share a little bit of what your setup looks like?

stevenschobert avatar Feb 09 '16 18:02 stevenschobert

Sure. I have a CLI and node interface that both end up programmatically triggering gulp build. That build task uses gulp-metalsmith to performs several operations. This code emulates a simplified version of the workflow:

gulp.task('build', build);
exec('gulp build');

function build() {
  gulp.src(['source/**', '!source/layouts/**', '!source/partials/**'])
        .pipe(plumber())
        .pipe(metalsmith({
          use: [
            markdown(),
            layouts({
              engine: 'handlebars',
              default: 'page.html',
              directory: 'source/layouts',
              partials: 'source/partials',
              pattern: '**/*.html'
            })
          ]
        }));

As you can see, ideally I can use your great tool inline with markdown() and layouts(), via gulp-metalsmith's use() property method.

Currently, I am using gulp-sass directly. This works great; however, I would ideally like to merge the operations.

Thanks a lot for your quick response.

EDIT: If interested, here is the precise implementation.

justinhelmer avatar Feb 09 '16 19:02 justinhelmer