@bananacool467/pt 0.1.0-beta.1 → 0.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +11 -6
  2. package/pt.js +12 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bananacool467/pt",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.3",
4
4
  "description": "Test your NPM packages without publishing them.",
5
5
  "keywords": [
6
6
  "test",
@@ -10,16 +10,21 @@
10
10
  "author": "bananacool467",
11
11
  "type": "module",
12
12
  "main": "pt.js",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/bananakitssu/pt.git"
16
+ },
13
17
  "bin": {
14
- "pt": "./pt.js"
18
+ "pt": "pt.js"
15
19
  },
16
20
  "scripts": {
17
- "test": "npm link && pt-build && pt-link"
18
- },
19
- "dependencies": {
20
- "chokidar": "^4.0.0"
21
+ "test": "npm link && pt-build && pt-link",
22
+ "prepublishOnly": "echo -e \"test\n\nnewline\""
21
23
  },
22
24
  "engines": {
23
25
  "node": ">=18.0.0"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
24
29
  }
25
30
  }
package/pt.js CHANGED
@@ -141,14 +141,18 @@ async function build () {
141
141
  const prepare = pkg.scripts.prepare;
142
142
  const script = prepublishOnly ? prepublishOnly : (prepare ? prepare : null);
143
143
  if (script) {
144
- console.log(` [|] Running \`${script}\` before copying files...`);
145
- child_process.exec(script, (error, stdout, stderr) => {
146
- if (error || stderr) {
147
- const err = error ? error : (stderr ? stderr : "an unknown error");
148
- throw new Error(` [X] Failed to run script. Got: \n${err}\n Stopping...`);
144
+ console.log(` [|] Running script for \`prepublishOnly\`/\`prepare\` before copying files...`);
145
+ try {
146
+ const stdout = child_process.execSync(script, { stdio: ['pipe', 'pipe', 'pipe'], encoding: 'utf8' });
147
+ if (stdout && stdout.trim()) {
148
+ const __stdout = stdout.trim().split("\n");
149
+ for (const __stdout_item of __stdout)
150
+ console.log(` [i] ${__stdout_item.trim()}`);
149
151
  }
150
- console.log(` [i] ${stdout.trim()}`);
151
- });
152
+ } catch (error) {
153
+ const errMessage = error.stderr ? error.stderr.trim() : error.message;
154
+ throw new Error(` [X] Failed to run script. Got: \n${errMessage}\n Stopping...`);
155
+ }
152
156
  }
153
157
  const __files = fs.readdirSync('.', { recursive: true });
154
158
  for (const file of __files) {
@@ -170,6 +174,7 @@ async function build () {
170
174
  fs.cpSync(file, path.join(__testPath, file), { recursive: true/*, filter: (src) => { return !src.includes('.git') && !src.includes(__testName); }*/ });
171
175
  }
172
176
  }
177
+ console.log(" [+] Successfully built package!");
173
178
  }
174
179
 
175
180
  async function main () {