mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
2
.vscode/launch.json
generated
vendored
2
.vscode/launch.json
generated
vendored
@@ -325,7 +325,7 @@
|
||||
"name": "bun install",
|
||||
"program": "bun-debug",
|
||||
"args": ["install"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"cwd": "${fileDirname}",
|
||||
"console": "internalConsole",
|
||||
"env": {
|
||||
"BUN_DEBUG_QUIET_LOGS": "1"
|
||||
|
||||
@@ -3103,9 +3103,10 @@ pub const Package = extern struct {
|
||||
string_builder.count(key);
|
||||
string_builder.count(value);
|
||||
|
||||
// If it's a folder, pessimistically assume we will need a maximum path
|
||||
if (Dependency.Version.Tag.infer(value) == .folder) {
|
||||
string_builder.cap += bun.MAX_PATH_BYTES;
|
||||
// If it's a folder or workspace, pessimistically assume we will need a maximum path
|
||||
switch (Dependency.Version.Tag.infer(value)) {
|
||||
.folder, .workspace => string_builder.cap += bun.MAX_PATH_BYTES,
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
total_dependencies_count += @truncate(u32, obj.properties.len);
|
||||
|
||||
@@ -50,4 +50,4 @@ should equal
|
||||
`),i=0;i<u.length;i++){var p=n.indexOf(u[i]);if(p!==-1){n=n.slice(0,p);break}}d.stack="".concat(n.join(`
|
||||
`),`
|
||||
`).concat(u.join(`
|
||||
`))}throw d}};function m(){for(var x=arguments.length,y=new Array(x),g=0;g<x;g++)y[g]=arguments[g];A.apply(void 0,[m,y.length].concat(y))}F.strict=G(m,F,{equal:F.strictEqual,deepEqual:F.deepStrictEqual,notEqual:F.notStrictEqual,notDeepEqual:F.notDeepStrictEqual}),F.strict.strict=F.strict}}),V1=U1();V1[Symbol.for("CommonJS")]=0;V1["CallTracker"]=D1;var{AssertionError:M1,assert:q1,deepEqual:v1,deepStrictEqual:G1,doesNotReject:T1,doesNotThrow:w1,equal:O1,fail:F1,ifError:N1,notDeepEqual:I1,notDeepStrictEqual:P1,notEqual:A1,notStrictEqual:S1,ok:j1,rejects:R1,strict:f1,strictEqual:C1,throws:E1}=V1,b1=V1;export{E1 as throws,C1 as strictEqual,f1 as strict,R1 as rejects,j1 as ok,S1 as notStrictEqual,A1 as notEqual,P1 as notDeepStrictEqual,I1 as notDeepEqual,N1 as ifError,F1 as fail,O1 as equal,w1 as doesNotThrow,T1 as doesNotReject,b1 as default,G1 as deepStrictEqual,v1 as deepEqual,q1 as assert,M1 as AssertionError};
|
||||
`))}throw d}};function m(){for(var x=arguments.length,y=new Array(x),g=0;g<x;g++)y[g]=arguments[g];A.apply(void 0,[m,y.length].concat(y))}F.strict=G(m,F,{equal:F.strictEqual,deepEqual:F.deepStrictEqual,notEqual:F.notStrictEqual,notDeepEqual:F.notDeepStrictEqual}),F.strict.strict=F.strict}}),V1=U1();V1[Symbol.for("CommonJS")]=0;V1.CallTracker=D1;var{AssertionError:M1,assert:q1,deepEqual:v1,deepStrictEqual:G1,doesNotReject:T1,doesNotThrow:w1,equal:O1,fail:F1,ifError:N1,notDeepEqual:I1,notDeepStrictEqual:P1,notEqual:A1,notStrictEqual:S1,ok:j1,rejects:R1,strict:f1,strictEqual:C1,throws:E1}=V1,b1=V1;export{E1 as throws,C1 as strictEqual,f1 as strict,R1 as rejects,j1 as ok,S1 as notStrictEqual,A1 as notEqual,P1 as notDeepStrictEqual,I1 as notDeepEqual,N1 as ifError,F1 as fail,O1 as equal,w1 as doesNotThrow,T1 as doesNotReject,b1 as default,G1 as deepStrictEqual,v1 as deepEqual,q1 as assert,M1 as AssertionError};
|
||||
|
||||
@@ -29,7 +29,7 @@ var bound = function(obj) {
|
||||
}, tmpdir = function() {
|
||||
var lazy = Symbol.for("Bun.lazy"), primordials = globalThis[lazy]("primordials"), { Bun: Bun2 } = primordials, env = Bun2.env;
|
||||
return tmpdir = function() {
|
||||
var path = env["TMPDIR"] || env["TMP"] || env["TEMP"] || "/tmp";
|
||||
var path = env.TMPDIR || env.TMP || env.TEMP || "/tmp";
|
||||
const length = path.length;
|
||||
if (length > 1 && path[length - 1] === "/")
|
||||
path = path.slice(0, -1);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1062,8 +1062,8 @@ var nodeFsConstants = constants, __getOwnPropNames = Object.getOwnPropertyNames,
|
||||
}
|
||||
}
|
||||
initWasiFdInfo() {
|
||||
if (this.env["WASI_FD_INFO"] != null) {
|
||||
const fdInfo = JSON.parse(this.env["WASI_FD_INFO"]);
|
||||
if (this.env.WASI_FD_INFO != null) {
|
||||
const fdInfo = JSON.parse(this.env.WASI_FD_INFO);
|
||||
for (let wasi_fd in fdInfo) {
|
||||
console.log(wasi_fd);
|
||||
const fd = parseInt(wasi_fd);
|
||||
|
||||
@@ -292,6 +292,50 @@ it("should handle workspaces", async () => {
|
||||
await access(join(package_dir, "bun.lockb"));
|
||||
});
|
||||
|
||||
it("should handle `workspace:` specifier", async () => {
|
||||
await writeFile(
|
||||
join(package_dir, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "Foo",
|
||||
version: "0.0.1",
|
||||
dependencies: {
|
||||
Bar: "workspace:path/to/bar",
|
||||
},
|
||||
}),
|
||||
);
|
||||
await mkdir(join(package_dir, "path", "to", "bar"), { recursive: true });
|
||||
await writeFile(
|
||||
join(package_dir, "path", "to", "bar", "package.json"),
|
||||
JSON.stringify({
|
||||
name: "Bar",
|
||||
version: "0.0.2",
|
||||
}),
|
||||
);
|
||||
const { stdout, stderr, exited } = spawn({
|
||||
cmd: [bunExe(), "install"],
|
||||
cwd: package_dir,
|
||||
stdout: null,
|
||||
stdin: "pipe",
|
||||
stderr: "pipe",
|
||||
env,
|
||||
});
|
||||
expect(stderr).toBeDefined();
|
||||
const err = await new Response(stderr).text();
|
||||
expect(err).toContain("Saved lockfile");
|
||||
expect(stdout).toBeDefined();
|
||||
const out = await new Response(stdout).text();
|
||||
expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([
|
||||
" + Bar@workspace:path/to/bar",
|
||||
"",
|
||||
" 1 packages installed",
|
||||
]);
|
||||
expect(await exited).toBe(0);
|
||||
expect(requested).toBe(0);
|
||||
expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "Bar"]);
|
||||
expect(await readlink(join(package_dir, "node_modules", "Bar"))).toBe(join("..", "path", "to", "bar"));
|
||||
await access(join(package_dir, "bun.lockb"));
|
||||
});
|
||||
|
||||
it("should handle workspaces with packages array", async () => {
|
||||
await writeFile(
|
||||
join(package_dir, "package.json"),
|
||||
|
||||
@@ -19,9 +19,9 @@ it("should download dependency to run local file", async () => {
|
||||
await writeFile(
|
||||
join(run_dir, "test.js"),
|
||||
`
|
||||
const { minify } = require("uglify-js@3.17.4");
|
||||
const { minify } = require("uglify-js@3.17.4");
|
||||
|
||||
console.log(minify("print(6 * 7)").code);
|
||||
console.log(minify("print(6 * 7)").code);
|
||||
`,
|
||||
);
|
||||
const { stdout, stderr, exited } = spawn({
|
||||
@@ -49,13 +49,13 @@ it("should download dependencies to run local file", async () => {
|
||||
await writeFile(
|
||||
join(run_dir, "test.js"),
|
||||
`
|
||||
import { file } from "bun";
|
||||
import decompress from "decompress@4.2.1";
|
||||
import { file } from "bun";
|
||||
import decompress from "decompress@4.2.1";
|
||||
|
||||
const buffer = await file("${join(import.meta.dir, "baz-0.0.3.tgz")}").arrayBuffer();
|
||||
for (const entry of await decompress(Buffer.from(buffer))) {
|
||||
console.log(\`\${entry.type}: \${entry.path}\`);
|
||||
}
|
||||
const buffer = await file("${join(import.meta.dir, "baz-0.0.3.tgz")}").arrayBuffer();
|
||||
for (const entry of await decompress(Buffer.from(buffer))) {
|
||||
console.log(\`\${entry.type}: \${entry.path}\`);
|
||||
}
|
||||
`,
|
||||
);
|
||||
const { stdout, stderr, exited } = spawn({
|
||||
|
||||
Reference in New Issue
Block a user