mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-13 21:27:54 +02:00
fix(tests): support npm pack object output
This commit is contained in:
@@ -6,6 +6,7 @@ const assert = require("assert")
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
const { spawnSync } = require("child_process")
|
||||
const { getNpmPackEntry } = require("../lib/npm-pack-output")
|
||||
|
||||
function runTest(name, fn) {
|
||||
try {
|
||||
@@ -54,7 +55,8 @@ function main() {
|
||||
assert.strictEqual(result.status, 0, result.error?.message || result.stderr)
|
||||
|
||||
const packOutput = JSON.parse(result.stdout)
|
||||
const packagedPaths = new Set(packOutput[0]?.files?.map((file) => file.path) ?? [])
|
||||
const packEntry = getNpmPackEntry(packOutput, packageJson.name)
|
||||
const packagedPaths = new Set(packEntry?.files?.map((file) => file.path) ?? [])
|
||||
|
||||
assert.ok(
|
||||
packagedPaths.has(".opencode/dist/index.js"),
|
||||
|
||||
@@ -11,6 +11,7 @@ const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
const { getNpmPackEntry } = require('../lib/npm-pack-output');
|
||||
|
||||
const repoRoot = path.join(__dirname, '..', '..');
|
||||
const packageJson = JSON.parse(
|
||||
@@ -123,14 +124,15 @@ function getPackedFixture() {
|
||||
['pack', '--json', '--ignore-scripts', '--pack-destination', directory]
|
||||
);
|
||||
const packOutput = JSON.parse(packResult.stdout);
|
||||
const filename = packOutput[0]?.filename;
|
||||
const packEntry = getNpmPackEntry(packOutput, packageJson.name);
|
||||
const filename = packEntry?.filename;
|
||||
assert.ok(filename, 'npm pack should report the archive filename');
|
||||
|
||||
packedFixture = {
|
||||
archivePath: path.join(directory, filename),
|
||||
directory,
|
||||
publishedPaths: new Set(
|
||||
packOutput[0]?.files?.map(file => file.path) || []
|
||||
packEntry?.files?.map(file => file.path) || []
|
||||
),
|
||||
};
|
||||
return packedFixture;
|
||||
|
||||
@@ -6,6 +6,7 @@ const assert = require("assert")
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
const { spawnSync } = require("child_process")
|
||||
const { getNpmPackEntry } = require("../lib/npm-pack-output")
|
||||
|
||||
function runTest(name, fn) {
|
||||
try {
|
||||
@@ -149,7 +150,8 @@ function main() {
|
||||
assert.strictEqual(result.status, 0, result.error?.message || result.stderr)
|
||||
|
||||
const packOutput = JSON.parse(result.stdout)
|
||||
const packagedPaths = new Set(packOutput[0]?.files?.map((file) => file.path) ?? [])
|
||||
const packEntry = getNpmPackEntry(packOutput, packageJson.name)
|
||||
const packagedPaths = new Set(packEntry?.files?.map((file) => file.path) ?? [])
|
||||
|
||||
for (const requiredPath of [
|
||||
"scripts/catalog.js",
|
||||
|
||||
Reference in New Issue
Block a user