chore(release): auto-load .env in release-sign script
This commit is contained in:
parent
e2246c0cfe
commit
76aaf8e137
1 changed files with 30 additions and 1 deletions
|
|
@ -8,6 +8,36 @@ const path = require('path');
|
|||
const { execSync } = require('child_process');
|
||||
|
||||
const root = path.join(__dirname, '..');
|
||||
|
||||
// Auto-load .env if present (no dependency on dotenv)
|
||||
(() => {
|
||||
try {
|
||||
const envPath = path.join(root, '.env');
|
||||
if (fs.existsSync(envPath)) {
|
||||
const content = fs.readFileSync(envPath, 'utf8');
|
||||
for (const rawLine of content.split(/\r?\n/)) {
|
||||
const line = rawLine.trim();
|
||||
if (!line || line.startsWith('#')) continue;
|
||||
const cleaned = line.startsWith('export ')
|
||||
? line.slice('export '.length).trim()
|
||||
: line;
|
||||
const eq = cleaned.indexOf('=');
|
||||
if (eq === -1) continue;
|
||||
const key = cleaned.slice(0, eq).trim();
|
||||
let val = cleaned.slice(eq + 1).trim();
|
||||
if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
|
||||
val = val.slice(1, -1);
|
||||
}
|
||||
if (!(key in process.env)) process.env[key] = val;
|
||||
}
|
||||
// Do not log secrets; just note that .env was processed
|
||||
console.log('Loaded environment from .env');
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Warning: Failed to load .env:', e.message);
|
||||
}
|
||||
})();
|
||||
|
||||
const pkg = require(path.join(root, 'package.json'));
|
||||
const manifest = require(path.join(root, 'manifest.json'));
|
||||
|
||||
|
|
@ -60,4 +90,3 @@ try {
|
|||
console.error('Release signing failed:', err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue