Skip to content

Commit

Permalink
feat: generate node info with install script (#18)
Browse files Browse the repository at this point in the history
* feat: generate node info with install script

* fix: improve bin name
  • Loading branch information
KSXGitHub authored Jul 5, 2024
1 parent f423e44 commit e839f90
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/generate-node-info-during-install/file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const BASE_NAME = 'node-info.json'
const FULL_PATH = require('path').join(__dirname, BASE_NAME)
module.exports = { BASE_NAME, FULL_PATH }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const fs = require('fs')
const file = require('./file')
const nodeInfo = {
execPath: process.execPath,
versions: process.versions,
}
const json = JSON.stringify(nodeInfo, undefined, 2) + '\n'
console.log(json)
fs.writeFileSync(file.FULL_PATH, json)
12 changes: 12 additions & 0 deletions packages/generate-node-info-during-install/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@pnpm.e2e/generate-node-info-during-install",
"version": "1.0.0",
"description": "Write a file that contains specs of the Node.js runtime that was used to install this package",
"scripts": {
"install": "node generate-node-info.js"
},
"index": "read-generated-node-info.js",
"bin": {
"print-generated-node-info": "print-generated-node-info.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /usr/bin/env node
const fs = require('fs')
const file = require('./file')
const json = fs.readFileSync(file.FULL_PATH, 'utf-8')
console.log(json)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const fs = require('fs')
const file = require('./file')
const json = fs.readFileSync(file.FULL_PATH, 'utf-8')
module.exports = JSON.parse(json)

0 comments on commit e839f90

Please sign in to comment.