@acryps/environment
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -123,9 +123,47 @@ "use strict"; | ||
} | ||
const save = () => { | ||
(0, fs_1.writeFileSync)(environmentSaveLocation, JSON.stringify(savedEnvironments, null, '\t')); | ||
}; | ||
checkConfiguration(environmentConfiguration, []).then(async () => { | ||
if (saveRequired) { | ||
(0, fs_1.writeFileSync)(environmentSaveLocation, JSON.stringify(savedEnvironments, null, '\t')); | ||
save(); | ||
} | ||
switch (childProgram[0]) { | ||
case '--switch': { | ||
if (childProgram.length != 2) { | ||
process.stderr.write(`missing arguments\nusage: environment --switch <setting>\nuse 'environment --settings' to list all previously created settings\n`); | ||
return process.exit(1); | ||
} | ||
projectSettings.active = childProgram[1].trim(); | ||
if (projectSettings.active in projectSettings.settings) { | ||
process.stdout.write(`switched to existing setting '${projectSettings.active}'\n`); | ||
} | ||
else { | ||
process.stdout.write(`switched to new setting '${projectSettings.active}'\n`); | ||
} | ||
save(); | ||
return process.exit(0); | ||
} | ||
case '--active-setting': { | ||
process.stdout.write(`${projectSettings.active}\n`); | ||
return process.exit(0); | ||
} | ||
case '--settings': { | ||
for (let setting in projectSettings.settings) { | ||
process.stdout.write(`${setting}\n`); | ||
} | ||
return process.exit(0); | ||
} | ||
case '--import': { | ||
if (childProgram.length != 2) { | ||
process.stderr.write(`missing arguments\nusage: environment --import <exported blob>\n`); | ||
return process.exit(1); | ||
} | ||
const settings = JSON.parse(Buffer.from(childProgram[1].trim(), 'base64').toString('utf-8')); | ||
projectSettings.settings[projectSettings.active] = settings; | ||
save(); | ||
return process.exit(0); | ||
} | ||
case '--export': { | ||
process.stdout.write(`${Buffer.from(JSON.stringify(environment), 'utf-8').toString('base64')}\n`); | ||
process.stdout.write(`environment --import ${Buffer.from(JSON.stringify(environment), 'utf-8').toString('base64')}\n`); | ||
return process.exit(0); | ||
@@ -132,0 +170,0 @@ } |
@@ -15,4 +15,4 @@ { | ||
"scripts": { | ||
"start": "environment index.js" | ||
"start": "environment node index.js" | ||
} | ||
} |
{ | ||
"name": "@acryps/environment", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"license": "GPL-3.0-only", | ||
@@ -5,0 +5,0 @@ "bin": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12489
238