only write config if file does not already exist
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
const prompt = require('prompt');
|
||||
fs = require('fs');
|
||||
const fs = require('fs');
|
||||
|
||||
const properties = [
|
||||
{
|
||||
name: 'superadmin username/email'
|
||||
name: 'username'
|
||||
},
|
||||
{
|
||||
name: 'superadmin password',
|
||||
name: 'password',
|
||||
hidden: true
|
||||
}
|
||||
];
|
||||
|
||||
console.log("Configure your test enviroment:")
|
||||
|
||||
const configPath = './cypress.env.json'
|
||||
|
||||
console.log("Configure your test enviroment")
|
||||
console.log("Enter CMS superadmin credentials:")
|
||||
|
||||
prompt.start();
|
||||
|
||||
@@ -23,10 +27,10 @@ var fileContent = `{
|
||||
"password": "${result.password}"
|
||||
}`;
|
||||
|
||||
fs.writeFile('cypress.env.json', fileContent, function (error) {
|
||||
fs.writeFile(configPath, fileContent, function (error) {
|
||||
if (error) return console.error(error);
|
||||
console.log('Configuration saved');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function onError(error) {
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"scripts": {
|
||||
"postinstall": "node createEnviromentConfiguration.js",
|
||||
"config": "node createEnviromentConfiguration.js",
|
||||
"postinstall": "node postinstall.js",
|
||||
"config": "node config.js",
|
||||
"test": "npx cypress run",
|
||||
"ui": "npx cypress open"
|
||||
},
|
||||
|
||||
14
src/Umbraco.Tests.AcceptanceTest/postinstall.js
Normal file
14
src/Umbraco.Tests.AcceptanceTest/postinstall.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const configPath = './cypress.env.json';
|
||||
|
||||
try {
|
||||
if (fs.existsSync(configPath)) {
|
||||
//file exists
|
||||
console.log("Skips configuration as file already exists, run 'npm run config' to change your configuration.");
|
||||
} else {
|
||||
require('./createEnviromentConfiguration.js');
|
||||
}
|
||||
} catch(err) {
|
||||
console.error(err)
|
||||
}
|
||||
Reference in New Issue
Block a user