Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Node.js package (binary-only) #15

Merged
merged 2 commits into from
May 31, 2024
Merged

Add Node.js package (binary-only) #15

merged 2 commits into from
May 31, 2024

Conversation

kylewlacy
Copy link
Member

This PR adds a new nodejs package.

  • The default export can be used as a dependency, giving the node and npm binaries
  • nodejs.npmInstall() takes an NPM package and downloads the dependencies while verifying the lockfile is up-to-date, returning the same package with a node_modules directory. It's effectively equivalent to running npm install.

This package does not currently build from source-- instead, it downloads and wraps an official Node.js binary. In the future, this will probably be replaced with a from-source build.

import * as std from "std";
import node, { npmInstall } from "nodejs";

export default () => {
  const npmPackage = npmInstall(
    Brioche.glob("package.json", "package-lock.json", "src"),
  );
  return std.runBash`
    node src/index.js
  `
    .workDir(npmPackage)
    .dependencies(node());
};

@kylewlacy kylewlacy merged commit f70b7d3 into main May 31, 2024
3 checks passed
@kylewlacy kylewlacy deleted the add-nodejs-package branch May 31, 2024 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant