nginx-pretty 1.0.2 → 1.0.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/cli.js +7 -5
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -6,12 +6,18 @@
6
6
  */
7
7
 
8
8
  const fs = require('fs');
9
+ const os = require('os');
9
10
  const path = require('path');
10
11
  const readline = require('readline');
11
12
  const { spawn } = require('child_process');
12
13
 
13
14
  const DEFAULT_CONFIG = '/etc/nginx/sites-available/default';
14
- const FORMATTED_TMP = '/tmp/tmp_nginx_formatted.conf';
15
+
16
+ /** User-specific temp path so we can write without sudo (avoids EACCES when /tmp/tmp_nginx_formatted.conf is root-owned). */
17
+ function getTempPath() {
18
+ const user = process.env.USER || process.env.USERNAME || String(process.getuid?.() || 'tmp');
19
+ return path.join(os.tmpdir(), `nginx-pretty-${user}-formatted.conf`);
20
+ }
15
21
 
16
22
  function loadBeautifier() {
17
23
  const beautifier = require('./beautifier');
@@ -57,10 +63,6 @@ Options:
57
63
  `);
58
64
  }
59
65
 
60
- function getTempPath() {
61
- return FORMATTED_TMP;
62
- }
63
-
64
66
  function runDiff(fileA, fileB) {
65
67
  return new Promise((resolve, reject) => {
66
68
  const proc = spawn('diff', ['-u', fileA, fileB], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nginx-pretty",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Safely format and apply NGINX config files. Never modifies originals unless confirmed. Shows diff, validates with nginx -t.",
5
5
  "main": "cli.js",
6
6
  "bin": {