Skip to content

Instantly share code, notes, and snippets.

@KSXGitHub
Last active January 20, 2018 15:16
Show Gist options
  • Save KSXGitHub/0795cf865df6d3e825c0969723ae2f45 to your computer and use it in GitHub Desktop.
Save KSXGitHub/0795cf865df6d3e825c0969723ae2f45 to your computer and use it in GitHub Desktop.
# This project
.DS_Store
.out
.out.*
out
out.*
*.*.map
quick-test
quick-test.*
tmp
temp
tmp.*
temp.*
*.tmp
*.temp
*.tern-project
*.tern-project.json
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
'use strict'
const {rng, prng} = require('crypto')
const path = require('path')
const os = require('os')
const {env} = require('process')
const {readFile, readdir, stat} = require('fs-extra')
const known = {
hello: 'world',
foo: 'bar',
today: new Date(),
env,
random: [
() => Math.random(),
() => rng(32).toString('base64'),
() => prng(32).toString('base64')
]
.map(x => [String(x), x()])
.reduce((obj, [key, val]) => Object.assign(obj, {[key]: val}), {}),
os: [
'arch', 'cpus', 'endianness', 'freemem',
'homedir', 'hostname', 'loadavg', 'networkInterfaces',
'platform', 'release', 'tmpdir', 'totalmem',
'type', 'uptime', 'userInfo'
]
.map(name => [name, os[name]()])
.reduce((obj, [key, val]) => Object.assign(obj, {[key]: val}), {})
}
const main = async () => {
const items = await readdir(__dirname)
const paths = items.map(x => path.resolve(__dirname, x))
const contents = (await Promise.all(
paths.map(async x => {
const isFile = (await stat(x)).isFile()
const content = await (isFile ? readFile(x, 'utf8') : readdir(x))
return [x, {isFile, content}]
})
))
.reduce(
(obj, [key, val]) => Object.assign(obj, {[key]: val}),
{}
)
return {
fs: {
items,
paths,
contents
},
...known
}
}
module.exports = main
{
"name": "now-test-json",
"version": "0.0.1",
"main": "index.js",
"author": "",
"license": "ISC",
"scripts": {
"start": "micro"
},
"dependencies": {
"fs-extra": "^5.0.0",
"micro": "^9.1.0"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://gist.github.com/0795cf865df6d3e825c0969723ae2f45.git"
},
"bugs": {
"url": "https://gist.github.com/0795cf865df6d3e825c0969723ae2f45"
},
"homepage": "https://gist.github.com/0795cf865df6d3e825c0969723ae2f45",
"description": ""
}
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
[email protected]:
version "3.0.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"
[email protected]:
version "1.0.4"
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b"
[email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359"
fs-extra@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-5.0.0.tgz#414d0110cdd06705734d055652c5411260c31abd"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"
graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
[email protected]:
version "1.6.2"
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736"
dependencies:
depd "1.1.1"
inherits "2.0.3"
setprototypeof "1.0.3"
statuses ">= 1.3.1 < 2"
[email protected]:
version "0.4.19"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
[email protected]:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
[email protected]:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
optionalDependencies:
graceful-fs "^4.1.6"
micro@^9.1.0:
version "9.1.0"
resolved "https://registry.yarnpkg.com/micro/-/micro-9.1.0.tgz#f2effba306639076e994c007c327dfc36a5185e9"
dependencies:
content-type "1.0.4"
is-stream "1.1.0"
mri "1.1.0"
raw-body "2.3.2"
[email protected]:
version "1.1.0"
resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.0.tgz#5c0a3f29c8ccffbbb1ec941dcec09d71fa32f36a"
[email protected]:
version "2.3.2"
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89"
dependencies:
bytes "3.0.0"
http-errors "1.6.2"
iconv-lite "0.4.19"
unpipe "1.0.0"
[email protected]:
version "1.0.3"
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04"
"statuses@>= 1.3.1 < 2":
version "1.4.0"
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087"
universalify@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7"
[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment