Skip to content

Instantly share code, notes, and snippets.

@matthewstokeley
Created March 3, 2020 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewstokeley/f8beae4e9a825a6cc909c246a8cc668a to your computer and use it in GitHub Desktop.
Save matthewstokeley/f8beae4e9a825a6cc909c246a8cc668a to your computer and use it in GitHub Desktop.
configuration file population, modular dependencies and modular task workflows
#! /usr/bin/node
/* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
* Bootload a Transpiling Environment
*
* @version 0.0.2
*/
/* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
* Declare Modules
*/
const config = require( './config' )
const fs = require( 'fs' )
const { exec, nextTick } = require( 'process' )
const events = require( 'events' )
const { spawn } = require('child_process')
const clc = require( 'cli-color' )
/* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
* Handle the configuration file
*/
const FILE_PATH = ''
const RESOURCE_PATH
let file_contents = ''
fs.access( PATH, fs.constants.F_OK | fs.constants.W_OK, ( err ) => {
if err throw error(err)
} )
events.addEventListener( '', ( fileExists ) => {
if ( ! fileExists )
fs.writeSync( PATH, '', ( err ) => { if err throw err } )
// @todo replace with the http module
let exec = process.exec( 'curl ${ RESOURCE_PATH } >> ${ PATH } ' )
exec.stdout.on( 'data', ( err, data ) => {
if err throw err
} )
}
// populate from a .env file
// process.exec( "touch output.txt && sed -e '/^$/d" "$1" >> output.txt )
// @todo
process.exec( "sed /awk '{print $1}' secret.env/awk '{print $2}' secret.env/ $FILE_PATH " )
/* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
* Spawn out our installation task
*/
let exec = spawn( 'npm install npm install @babel/core babel-loader @babel/preset-env @babel/preset-modules',
[ '--save-dev' ] )
let err = ( status_code ) => {
console.log( "Error: " + status_code )
}
exec.stdout.on( 'data', () => {
console.log( '' )
} )
exec.stderr.on( 'data', status_code )
exec.on( 'close', () => {} )
// Add Gulp Task
process.exec( 'touch gulpfile.js && echo "gulp.task( "transpile", () => { gulp.pipe("./app/").babel().dest() } )" >> gulpfile.json' )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment