View index.js
'use strict'
const fs = require('fs')
const path = require('path')
const isCaseSensitive = (p, cb) => {
if (/[a-z]/.test(p))
test(p, p.toUpperCase(), cb)
else if (/[A-Z]/.test(p))
test(p, p.toLowerCase(), cb)
View gist:f06bf8818513732cd02ec8aec13a75ba
$ find . -type f
./docs/foo/thing.js
./docs/thing.js
./docs/nope.txt
./docs-src/foo/thing.js
./docs-src/thing.js
./x.sh
./client/docs/foo/thing.js
./client/docs/thing.js
./client/docs/nope.txt
View h.js
'use strict'
const test = require('tap').test
const server = {
inject: options => new Promise(r => r({ statusCode: 200, payload: 'Hello world' }))
}
test('Home entry', async t => {
const options = {
method: 'GET',
url: '/'
View smodule.js
const s = require('http').createServer((q, s) => {
console.error(q.method, q.url)
switch (q.url) {
case '/':
return html(s)
case '/app.js':
return js(s)
View _
$ tar cvf x.tar package
a package
a package/.gitignore
$ node rename.js
entry package/
extracting package/
entry package/.gitignore
renaming package/.gitignore to package/.npmignore
extracting package/.npmignore
View example
$ tree x
x
└── y/
└── z/
└── .gitignore
2 directories, 1 file
$ tar cf x.tar x
View gist:b20156c0091cc071453d455446a5b105
$ cat make-tar.js
'use strict'
const makeTar = require('./test/make-tar.js')
const fs = require('fs')
const data = makeTar([
{
type: 'SymbolicLink',
linkpath: './foo',
mode: 0o0644
View rename.js
'use strict'
const tar = require('./')
const fs = require('fs')
const rimraf = require('rimraf')
const mkdirp = require('mkdirp')
rimraf.sync('input')
rimraf.sync('output')
mkdirp.sync('input/foo')
mkdirp.sync('output/foo')
View servers.js
const http = require('http')
const firstServer = http.createServer((req, res) => {
console.log('firstServer request', req.url, req.headers)
res.setHeader('set-cookie', 'foo=bar; max-age=10000000; host=localhost:8080; SameSite=Strict')
res.setHeader('content-type', 'text/html')
res.write('<pre>')
res.write(JSON.stringify(req.headers, null, 2) + '\n</pre>')
View labeled-continue.js
'use strict'
let i = 0
OUTER: while (true) {
console.log('outer before', i)
INNER: while (true) {
i++
console.log('inner before', i)
if (i > 10)