static-dev / spike-collections

jekyll-esque dynamic content for spike
Other
18 stars 4 forks source link

Error installing with Spike 1.3.1 #19

Closed waynehoover closed 7 years ago

waynehoover commented 7 years ago

I get this error when trying to install spike-collections with Spike 1.3.1.

❯ node --version
v8.1.2
❯ ./node_modules/spike/bin/spike --version
1.3.1
❯ ./node_modules/spike/bin/spike watch
.../node_modules/objectfn/index.js:75
  for (let key of Object.keys(obj)) {
                         ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at entries (.../node_modules/objectfn/index.js:75:26)
    at entries.next (<anonymous>)
    at map (.../node_modules/objectfn/index.js:19:23)
    at partial (.../node_modules/objectfn/index.js:101:7)
    at callWithReorderedArgs (.../node_modules/objectfn/index.js:90:19)
    at partial (.../node_modules/objectfn/index.js:101:7)
    at args.length.fn.length.partialArgs (.../node_modules/objectfn/index.js:100:27)
    at SpikeCollections.apply (.../node_modules/spike-collections/lib/index.js:47:18)
    at Compiler.apply (/usr/local/lib/node_modules/spike/node_modules/tapable/lib/Tapable.js:306:16)

config is

const htmlStandards = require('reshape-standard')
const cssStandards = require('spike-css-standards')
const jsStandards = require('spike-js-standards')
const pageId = require('spike-page-id')
const Collections = require('spike-collections')
const env = process.env.NODE_ENV
const locals = {}
const collections = new Collections({
  addDataTo: locals
})

module.exports = {
  devtool: 'source-map',
  matchers: { html: '*(**/)*.sgr', css: '*(**/)*.sss' },
  ignore: ['**/layout.sgr', '**/_*', '**/.*', 'readme.md', 'yarn.lock'],
  reshape: htmlStandards({
    locals: (ctx) => Object.assign(collections.locals(ctx, locals), {pageId: pageId(ctx)}),
    minify: env === 'production'
  }),
  postcss: cssStandards({
    minify: env === 'production',
    warnForDuplicates: env !== 'production'
  }),
  babel: jsStandards(),
  plugins: [collections]
}
jescalan commented 7 years ago

Hey @waynehoover! Thanks for the clear issue -- I took a look, found out what the issue is, and just submitted a patch, referenced below. I'll have this patch out today and it should fix your issue. The problem was that there was a bug with injecting the default of "posts/**", so it would only work if done manually. If you want an immediate fix, You can just add the following to your collections call. Alternately, an upgrade to this patch version which is soon to be released will fix it with no changes.

new Collections({
  addDataTo: locals,
  collections: { posts: { files: 'posts/**' } }
})