Last active
June 3, 2016 03:29
-
-
Save lowellbander/e4793e6c5b2bdfb5d449d3399d97ae09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // run me in the desired directory: `node --harmony genPieces.js` | |
| var fs = require('fs'); | |
| var directory = process.cwd(); | |
| String.prototype.contains = _ => this.indexOf(_) != -1; | |
| var pieces = fs.readdirSync(directory) | |
| .filter(_ => _.contains('.png') || _.contains('jpg')) | |
| .map(_ => { | |
| var title = _.substring(0, _.indexOf('.')); | |
| return '\nnew Piece({\n\ttitle: \'' + title + '\',\n\t' | |
| + 'description: \'a description for ' + title + '\',\n\t' | |
| + 'photoURL: \'photos/' + _ + '\'\n})'; | |
| }).join(','); | |
| console.log('[' + pieces + ']'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment