Skip to content

Commit

Permalink
extract lib/ to tape-lib subpackage
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jun 18, 2024
1 parent 4ed8e77 commit e47b9e2
Show file tree
Hide file tree
Showing 19 changed files with 1,395 additions and 1,284 deletions.
8 changes: 4 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
},
},
{
"files": ["lib/results.js"],
"files": ["packages/lib/results.js"],
"rules": {
"no-cond-assign": "warn",
"no-param-reassign": "warn",
"no-plusplus": "warn",
},
},
{
"files": ["lib/test.js"],
"files": ["packages/lib/test.js"],
"rules": {
"eqeqeq": "warn",
"func-name-matching": "off",
Expand Down Expand Up @@ -120,13 +120,13 @@
},
},
{
"files": ["lib/default_stream.js"],
"files": ["packages/lib/default_stream.js"],
"rules": {
"no-use-before-define": "warn",
},
},
{
"files": ["lib/test.js"],
"files": ["packages/lib/test.js"],
"rules": {
"max-lines": "off",
},
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/node-aught.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ jobs:
range: '< 10'
type: minors
command: npm run tests-only
subpackage: ./lib
17 changes: 16 additions & 1 deletion .github/workflows/node-pretest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,19 @@ jobs:
tests:
uses: ljharb/actions/.github/workflows/pretest.yml@main
with:
skip-engines: true # bin/tape requires node 8+, but the rest of tape supports 0.4+
skip-engines: true # bin/tape requires node 8+, but tape-lib supports 0.4+. TODO: fix and add engines.node in v6

engines-lib:
runs-on: ubuntu-latest
steps:
- uses: ljharb/actions/node/engines@main
with:
working-directory: lib

pack-lib:
runs-on: ubuntu-latest
steps:
- uses: ljharb/actions/node/pack@main
with:
after_install: cd ../ && npm install
working-directory: lib
1 change: 1 addition & 0 deletions .github/workflows/node-tens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ jobs:
range: '>= 10'
type: minors
command: npm run tests-only
subpackage: ./lib
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# gitignore

/node_modules
**/node_modules
!node_modules/tape-lib

# Only apps should have lockfiles
yarn.lock
Expand Down
2 changes: 1 addition & 1 deletion bin/tape
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var files = opts._.reduce(function (result, arg) {

var hasImport = require('has-dynamic-import');

var tape = require('../');
var tape = require('tape-lib');

function importFiles(hasSupport) {
if (!hasSupport) {
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('tape-lib');
3 changes: 3 additions & 0 deletions lib/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package-lock=false
allow-same-version=true
message=v%s
51 changes: 1 addition & 50 deletions lib/default_stream.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,3 @@
'use strict';

var through = require('@ljharb/through');
var fs = require('fs');

module.exports = function () {
var line = '';
var stream = through(write, flush);
return stream;

function write(buf) {
if (
buf == null // eslint-disable-line eqeqeq
|| (Object(buf) !== buf && typeof buf !== 'string')
) {
flush();
return;
}
for (var i = 0; i < buf.length; i++) {
var c = typeof buf === 'string'
? buf.charAt(i)
: String.fromCharCode(buf[i]);
if (c === '\n') {
flush();
} else {
line += c;
}
}
}

function flush() {
if (fs.writeSync && (/^win/).test(process.platform)) {
try {
fs.writeSync(1, line + '\n');
} catch (e) {
stream.emit('error', e);
}
} else {
try {
if (typeof console !== 'undefined' && console.log) { // eslint-disable-line no-console
console.log(line); // eslint-disable-line no-console
} else if (typeof document !== 'undefined') {
// for IE < 9
document.body.innerHTML += line + '<br />';
}
} catch (e) {
stream.emit('error', e);
}
}
line = '';
}
};
module.exports = require('tape-lib/default_stream');
71 changes: 71 additions & 0 deletions lib/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "tape-lib",
"version": "0.0.0",
"description": "TAP-producing test harness library for node and browsers",
"main": "index.js",
"browser": {
"fs": false
},
"exports": {
".": "./index.js",
"./default_stream": "./default_stream.js",
"./results": "./results.js",
"./test": "./test.js",
"./package.json": "./package.json"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated --gitignore=../.gitignore",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"",
"prepublishOnly": "safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"tests-only": "cd ../ && npm run tests-only",
"test": "cd ../ && npm test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ljharb/tape.git",
"directory": "lib"
},
"author": "Jordan Harband <ljharb@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/ljharb/tape/issues"
},
"homepage": "https://github.com/ljharb/tape/#readme",
"keywords": [
"tap",
"test",
"harness",
"assert",
"browser"
],
"dependencies": {
"@ljharb/resumer": "^0.0.1",
"@ljharb/through": "^2.3.11",
"array.prototype.every": "^1.1.5",
"call-bind": "^1.0.5",
"deep-equal": "^2.2.3",
"defined": "^1.0.1",
"for-each": "^0.3.3",
"hasown": "^2.0.0",
"inherits": "^2.0.4",
"is-regex": "^1.1.4",
"mock-property": "^1.0.3",
"object-inspect": "^1.13.1",
"object-is": "^1.1.5",
"object-keys": "^1.1.1",
"string.prototype.trim": "^1.2.8"
},
"engines": {
"node": ">= 0.4"
},
"publishConfig": {
"ignore": []
},
"devDependencies": {
"in-publish": "^2.0.1",
"npmignore": "^0.3.0",
"safe-publish-latest": "^2.0.0"
}
}
Loading

0 comments on commit e47b9e2

Please sign in to comment.