Skip to content

Instantly share code, notes, and snippets.

@lucaronca
lucaronca / Category
Last active March 27, 2018 09:50
Script to get the stickers configuration reading from a given folder containing them
/**
*
* Install global modules: yarn global add typescript ts-node
* Install image utility libraries: npm i svgson calipers calipers-png
* Launch with ts-node ex:
* curl -sL <script_shortlink> -o ./c.ts && ts-node <path_to_sticker_folder> && rm ./c.ts
*
**/
const { promisify } = require('util')
#!/usr/bin/env bash
for package_json_path in `find ./packages -name package.json`; do
eslint_content="{
\"rules\": {
\"import/no-extraneous-dependencies\": [
\"error\",
{
\"packageDir\": \"${package_json_path//package.json}\",
\"devDependencies\": [\"**/*.test.js\", \"**/*.stories.js\"]
// Example: node --experimental-modules update_dep.mjs <package_dir_path>
import fs from 'fs';
import path from 'path';
const packageJsonPath = path.join(process.argv[2], './package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
const packageNames = Object.keys(packageJson.dependencies).filter(name => name.startsWith('@adespresso/'));
const pipeActions = reducer => (...actions) => {
const getStateAfterActions = (state, actionToExecute, ...actions) => {
return actionToExecute ?
getStateAfterActions(reducer(state, actionToExecute), ...actions) :
state;
};
return getStateAfterActions(undefined, ...actions);
};
def derive_relations(derived_down, target, relations):
for down, up in relations:
if target == down:
if (derived_down, up) in relations:
continue
if derived_down:
relations.append((derived_down, up))
derive_relations(target, up, relations)