Skip to content

Commit

Permalink
export object instead of array
Browse files Browse the repository at this point in the history
  • Loading branch information
pemrouz committed Jul 3, 2016
1 parent ab6c51b commit 63a2251
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
15 changes: 5 additions & 10 deletions export
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ var write = require('fs').writeFileSync
, resolve = require('path').resolve
, glob = require('glob').sync
, utilise = require('utilise')

, beautify = require('js-beautify').js_beautify

var root = resolve(process.cwd(), process.argv[2] || 'dist/resources')
, resources = str(glob(root+'/**/!(test|index).{js,css}')
.map(resource))
, resources = beautify(str(glob(root+'/**/!(test|index).{js,css}')
.map(resource)
.reduce(to.obj('name'), {})))
.replace(/"require\((.*?)\)"/g, 'require($1)')
.replace(/({"name")/g, '\n$1')
.replace(/([^:\s])(require\()/g, '$1\n$2')

write(resolve(root, 'index.js'), 'module.exports = ' + resources)

Expand Down Expand Up @@ -44,11 +44,6 @@ function resource(path) {
return res
}

function fn(body) {
return str(body)
.replace(/\\n/g, '\n')
}

function rel(path) {
return relative(root, path)
.replace(/\\/g, '\/')
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"url": "git://github.com/rijs/export.git"
},
"license": "pemrouz.mit-license.org",
"bin": "./export"
"bin": "./export",
"devDependencies": {
"js-beautify": "^1.6.3"
}
}

0 comments on commit 63a2251

Please sign in to comment.