Skip to content

Commit

Permalink
auto load datamosh modes
Browse files Browse the repository at this point in the history
  • Loading branch information
tlaskey committed Jul 11, 2020
1 parent 3f7621c commit 2cc1318
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/mosh.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Jimp = require('jimp')

const debug = require('util').debuglog('mosh')
const path = require('path')
const fs = require('fs')

module.exports = mosh

Expand Down Expand Up @@ -40,6 +41,19 @@ function mosh (options, cb) {
}
}

mosh.MODES = {}

const modeNames = fs.readdirSync(path.join(__dirname, '/modes'))

modeNames.forEach((name) => {
if (name.endsWith('.js')) {
name = name.slice(0, name.indexOf('.'))
mosh.MODES[name] = require(`./modes/${name}`)
}
})

console.log(mosh.MODES)

/* lean on jimp for img encoding */
Jimp.read(read)
.then(doMosh)
Expand Down Expand Up @@ -90,11 +104,3 @@ function mosh (options, cb) {
}
}
}

mosh.MODES = {
blurbobb: require('./modes/blurbobb'),
schifty: require('./modes/schifty'),
veneneux: require('./modes/veneneux'),
vana: require('./modes/vana'),
fatcat: require('./modes/fatcat')
}

0 comments on commit 2cc1318

Please sign in to comment.