diff --git a/packages/generate-node-info-during-install/file.js b/packages/generate-node-info-during-install/file.js new file mode 100644 index 0000000..e7a8d2a --- /dev/null +++ b/packages/generate-node-info-during-install/file.js @@ -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 } diff --git a/packages/generate-node-info-during-install/generate-node-info.js b/packages/generate-node-info-during-install/generate-node-info.js new file mode 100644 index 0000000..b513aba --- /dev/null +++ b/packages/generate-node-info-during-install/generate-node-info.js @@ -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) diff --git a/packages/generate-node-info-during-install/package.json b/packages/generate-node-info-during-install/package.json new file mode 100644 index 0000000..7c44eb8 --- /dev/null +++ b/packages/generate-node-info-during-install/package.json @@ -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" + } +} diff --git a/packages/generate-node-info-during-install/print-generated-node-info.js b/packages/generate-node-info-during-install/print-generated-node-info.js new file mode 100755 index 0000000..9c8cdbd --- /dev/null +++ b/packages/generate-node-info-during-install/print-generated-node-info.js @@ -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) diff --git a/packages/generate-node-info-during-install/read-generated-node-info.js b/packages/generate-node-info-during-install/read-generated-node-info.js new file mode 100644 index 0000000..5d7699b --- /dev/null +++ b/packages/generate-node-info-during-install/read-generated-node-info.js @@ -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)