Skip to content

Commit

Permalink
feat: install standard js and apply to code
Browse files Browse the repository at this point in the history
  • Loading branch information
Attila Max Ruf committed Jan 7, 2020
1 parent 73554de commit ce002d7
Show file tree
Hide file tree
Showing 5 changed files with 1,086 additions and 33 deletions.
29 changes: 14 additions & 15 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,28 @@ const rollupConfig = [
format: 'esm',
dir: Paths.Dist,
entryFileNames: '[name].js'
}),
})
// Object.freeze({
// format: 'iife',
// dir: Paths.Dist,
// entryFileNames: '[name].iife.js'
// })
]


// Magic
async function compile({ inputOpts, outputOpts }) {
async function compile ({ inputOpts, outputOpts }) {
const bundle = await rollup.rollup(inputOpts)

await bundle.generate(outputOpts)
await bundle.write(outputOpts)
}

function compileInit(iconList) {
function compileInit (iconList) {
console.log(`compiling ${iconList.length} icons`)
const offset = cpus().length;
const offset = cpus().length

return rollupConfig.map(async (output) => {
let i = 0;
let i = 0

console.log(`compiling '${output.format}' modules`)

Expand All @@ -51,35 +50,35 @@ function compileInit(iconList) {
rollupPluginCjs(),
rollupPluginVue()
],
input: iconList.slice(i, i + offset),
input: iconList.slice(i, i + offset)
},
outputOpts: output
})
} while((i += offset) < iconList.length)
} while ((i += offset) < iconList.length)
})
}

async function build() {
async function build () {
console.log('Building Material Design Icons')

await makeDir(Paths.Dist)

const svgList = Object.entries(mdi).slice(1)
const iconList = []

for(let [key, svgPath] of svgList) {
for (const [key, svgPath] of svgList) {
try {
const [raw, name] = key.match(/^mdi(\w+)/i)
const [, name] = key.match(/^mdi(\w+)/i)
const fileName = path.resolve(Paths.Dist, `${name}.vue`)

const component = template(kebabCase(name), svgPath, name)

const fh = await fsp.open(fileName, 'w')
await fh.writeFile(component)
fh.close();
fh.close()

iconList.push(fileName)
} catch(e) {
} catch (e) {
console.error('I DON\'T CARE!')
console.error(e)
}
Expand All @@ -89,4 +88,4 @@ async function build() {
}

// Fun!
build()
build()
2 changes: 1 addition & 1 deletion consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ const Paths = Object.freeze({

module.exports = {
Paths
}
}
3 changes: 1 addition & 2 deletions copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const path = require('path')
const makeDir = require('make-dir')
const Paths = require('./consts').Paths


async function copyDependencies() {
async function copyDependencies () {
await makeDir(Paths.Dist)

return Promise.all([
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"author": "Attila Max Ruf <therufa@gmail.com>",
"license": "(MIT AND OFL-1.1)",
"scripts": {
"lint": "standard",
"test": "standard",
"clean": "rimraf dist",
"build": "node build",
"release": "standard-version -a",
Expand All @@ -48,6 +50,7 @@
"rollup": "^1.16.7",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-vue": "^4.7.2",
"standard": "^14.3.1",
"standard-version": "^7.0.1",
"vue-runtime-helpers": "^1.1.2",
"vue-template-compiler": "^2.6.10"
Expand Down
Loading

0 comments on commit ce002d7

Please sign in to comment.