Skip to content

Instantly share code, notes, and snippets.

View pawelgalazka's full-sized avatar

Paweł Gałązka pawelgalazka

View GitHub Profile
@pawelgalazka
pawelgalazka / runfile.js
Last active November 12, 2017 04:36
code scaffolding - medium article
const fs = require('fs')
const path = require('path')
const dedent = require('dedent')
const { run } = require('runjs')
function createComponent(filePath) {
const dirName = path.basename(filePath)
const componentName = dirName.toUpperCase()
const content = dedent`
@pawelgalazka
pawelgalazka / package.json
Last active November 8, 2017 13:40
npm scripts downsides - medium article
{
"scripts": {
"build_closure_core": "node ./tools/make-closure-core.js",
"build_global": "npm-run-all clean_dist_global build_esm5_for_rollup && mkdirp ./dist/global && node ./tools/make-umd-bundle.js && npm-run-all build_closure_core clean_dist_esm5_for_rollup",
"build_perf": "webdriver-manager update && npm-run-all build_cjs build_global perf",
"decision_tree_widget": "cd doc/decision-tree-widget && npm run build && cd ../..",
"generate_packages": "node .make-packages.js",
"perf_micro": "node ./perf/micro/index.js",
"tests2png": "tsc && mkdirp tmp/docs/img && mkdirp spec-js/support && shx cp spec/support/*.opts spec-js/support/ && mocha --opts spec/support/tests2png.opts spec-js",
}
@pawelgalazka
pawelgalazka / package.json
Last active November 8, 2017 13:34
npm scripts downsides - medium article
{
"preinstall": "node tools/nodeVersionCheck.js",
"setup": "node tools/setup/setupMessage.js && npm install && node tools/setup/setup.js",
"remove-demo": "babel-node tools/removeDemo.js",
"start-message": "babel-node tools/startMessage.js",
"open:src": "babel-node tools/srcServer.js",
"open:dist": "babel-node tools/distServer.js",
"analyze-bundle": "babel-node ./tools/analyzeBundle.js"
}
@pawelgalazka
pawelgalazka / runfile.js
Created November 6, 2017 06:03
Example of runfile.js (for medium article)
export * from 'shared-tasks'
export function local () {
}
@pawelgalazka
pawelgalazka / runfile.js
Last active November 6, 2017 06:00
Example of runfile.js (for medium article)
import { help } from 'runjs'
export function build () {
}
help(build, 'Generates JS bundle')
@pawelgalazka
pawelgalazka / package.json
Last active April 21, 2017 22:14
package.json pattern for react component
{
"name": "react-component",
"version": "1.0.0",
"main": "lib/index.js",
"scripts": {
"build": "babel src --out-dir lib --ignore test.js",
"lint": "eslint src",
"test": "npm run lint && npm run build && jest --env=jsdom",
"clean": "rm -rf node_modules"
},
@pawelgalazka
pawelgalazka / runfile.js
Created October 4, 2016 02:10
runjs tricks example (medium article)
import { run } from 'runjs'
function log () {
}
export function start () {
run('http-server .', {async: true}).then((output) => {
log(output)
}).catch((error) => {
@pawelgalazka
pawelgalazka / runfile.js
Created October 4, 2016 02:08
runjs tricks example (medium article)
import { run } from 'runjs'
export function clean () {
}
export function build () {
process.on('SIGINT', clean)
try {
} catch (e) {
@pawelgalazka
pawelgalazka / runfile.js
Created October 4, 2016 02:07
runjs tricks example (medium article)
import { run } from 'runjs'
export function test (what, mode = 'node') {
if (mode == 'browser') {
} else {
}
}
@pawelgalazka
pawelgalazka / runfile.js
Last active August 9, 2017 08:41
Example of runfile.js (for medium article)
import { run, option } from 'runjs'
export function clean () {
run('rm -rf node_modules')
run('rm -rf build')
}
export function lint (path = '.') {
option(this, 'fix') ? run(`eslint ${path} --fix`) : run(`eslint ${path}`)
}