Skip to content

Instantly share code, notes, and snippets.

View vmarchesin's full-sized avatar
🐬
So Long, and Thanks for All the Fish

Vinicius Marchesin Araujo vmarchesin

🐬
So Long, and Thanks for All the Fish
View GitHub Profile
@vmarchesin
vmarchesin / index.js
Last active March 8, 2019 17:07
infinity-snap index.js
#! /usr/bin/env node
const { array, spawn: { sh } } = require('./utils');
const { options } = require('./cli');
const fs = require('fs');
// Calls the async function that spawns the child process
async function getFiles(path) {
const { stdout } = await sh(path);
// A helper to shuffle the filenames inside the array, ensuring randomness
@vmarchesin
vmarchesin / spawn.js
Last active March 8, 2019 17:01
infinity-snap Spawn.js
const { spawn } = require('child_process');
const readline = require('readline');
async function sh(path) {
return new Promise(function (resolve, reject) {
// Creates a process that runs asynchronously
const result = spawn('find', [path, '-type', 'f']);
let lines = [];
const rl = readline.createInterface({ input: result.stdout });
@vmarchesin
vmarchesin / webpack.config.js
Created January 18, 2019 16:36
how-to-publish-a-npm-package
const path = require('path');
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
path: path.resolve('dist'),
filename: 'index.js',
libraryTarget: 'commonjs2',
},
@vmarchesin
vmarchesin / bool.js
Last active May 27, 2020 10:26
how-to-publish-a-npm-package
const bool = () => Boolean(Math.round(Math.random()));
export default bool;