-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate node info with install script (#18)
* feat: generate node info with install script * fix: improve bin name
- Loading branch information
Showing
5 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
9 changes: 9 additions & 0 deletions
9
packages/generate-node-info-during-install/generate-node-info.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/generate-node-info-during-install/print-generated-node-info.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
4 changes: 4 additions & 0 deletions
4
packages/generate-node-info-during-install/read-generated-node-info.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |