Bash CLI to watch a file and execute commands on file update
- Download the checkmod.sh file
- Copy the checkmod.sh file and give permissions to execute
$ cp checkmod.sh /usr/bin/checkmod
$ chmod +x /usr/bin/checkmod
<html> | |
<head> | |
<title>WDD</title> | |
</head> | |
<body> | |
<div id="content"></div> | |
<script src="./build/vendor.bundle.js"></script> | |
<script src="./build/index.bundle.js"></script> | |
<script> | |
window.renderWidget('#content', 'user') |
const widgetMap = {} | |
const requireContext = require.context('../src', true, /\.widget.jsx$/) | |
const modulesPathList = requireContext.keys() | |
const widgetNameRegex = /[a-z-A-Z]+(?=\.widget\.jsx$)/ | |
for (const path of modulesPathList) { | |
widgetMap[widgetNameRegex.exec(path)[0]] = requireContext(path) | |
} | |
export default widgetMap |
import React from 'react' | |
import widgetMap from './widgetMap' | |
function getLazyComponent(widgetName, defaultProps, loader = 'loading...') { | |
if (!widgetMap[widgetName]) | |
throw 'WidgetNotFound: Provided widget name does not exist.' | |
return ( | |
class LoaderWrapper extends React.Component { | |
static defaultProps = defaultProps |
import React from 'react' | |
import ReactDOM from 'react-dom' | |
import getLazyComponent from './getLazyComponent' | |
function renderWidget(domSelector, widgetName, props) { | |
ReactDOM.render( | |
React.createElement(getLazyComponent(widgetName, props)), | |
document.querySelector(domSelector) | |
) | |
} |
const path = require('path') | |
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin'); | |
const BUNDLE_LOADER_RULES = [ | |
{ | |
test: /.*\/admin\/.*\.widget\.jsx$/, | |
use: [ | |
{ | |
loader: 'bundle-loader', | |
options: { |
function thresholder(callback, holdMillis, resetOnEachCall) { | |
let timer = null | |
let args | |
return function() { | |
args = arguments | |
if (timer && resetOnEachCall) { | |
clearTimeout(timer) | |
timer = null |
function curry(callable) { | |
return function(...args) { | |
if (callable.length <= args.length) { | |
return callable.apply(null, args) | |
} else { | |
return curry(callable).bind(null, ...args) | |
} | |
} | |
} |
import * as React from 'react' | |
import { StyledComponent } from './StyledComponent' | |
function Spinner(props) { | |
return ( | |
<div className={'w--spinner ' + props.customClass}> | |
<div className="bounce1" /> | |
<div className="bounce2" /> | |
<div className="bounce3" /> | |
</div> |
module Loop exposing (forEach) | |
loop : List a -> List b -> (a -> Int -> b) -> List b | |
loop a b fn = | |
case a of | |
[] -> | |
b | |
x::xs -> | |
loop xs (b ++ [(fn x (List.length b))]) fn |