Skip to content

Commit

Permalink
🔧 Kreedzt - modify config file path
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreedzt committed May 18, 2020
1 parent d80bcca commit 150310c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ web/
*.log

# config file
envFile
src/proxy
src/webVersion.json
src/releaseVersion.json
config/

#index file
GPATH
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
"filter": [
"**/*"
]
},
{
"from": "config",
"to": "config",
"filter": [
"**/*"
]
}
],
"nsis": {
Expand Down
4 changes: 2 additions & 2 deletions setVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const initializeEnv = async () => {

if (commitInfo) {
fs.writeFileSync(
path.join(__dirname, './src/webVersion.json'),
path.join(__dirname, './config/webVersion.json'),
JSON.stringify(commitInfo, null, 2),
encode
);
Expand All @@ -18,7 +18,7 @@ const initializeEnv = async () => {

if (releaseInfo) {
fs.writeFileSync(
path.join(__dirname, './src/releaseVersion.json'),
path.join(__dirname, './config/releaseVersion.json'),
JSON.stringify(releaseInfo, null, 2),
encode
);
Expand Down
2 changes: 1 addition & 1 deletion src/proxyConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const initializeWindow = () => {
}
});

proxyWindow.loadFile(getCorrectPath('src/proxyWebConfig.html'));
proxyWindow.loadFile(getCorrectPath('src/proxyWebConfig.html', './'));

proxyWindow.on('closed', () => {
proxyWindow = null;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/autoUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const autoUpdateWebPage = async () => {
let isUpdated = false;
logger.info('autoUpdateWebPage fn');
try {
const currentInfo = JSON.parse(await promisedReadFile(getCorrectPath('src/webVersion.json')));
const currentInfo = JSON.parse(await promisedReadFile(getCorrectPath('config/webVersion.json')));
logger.info('current web page version', currentInfo);
const latestInfo = await getWebPageCommit();
logger.info('latest web page version', latestInfo);
Expand All @@ -33,7 +33,7 @@ const autoUpdateWebPage = async () => {

// when success, write version info to file
if (isSuccess) {
await promisedWriteFile(getCorrectPath('src/webVersion.json'), JSON.stringify(latestInfo, null, 2));
await promisedWriteFile(getCorrectPath('config/webVersion.json'), JSON.stringify(latestInfo, null, 2));
logger.info('write latest web page version info success');
}
}
Expand All @@ -52,7 +52,7 @@ const checkApplicationRelease = async () => {
logger.info('checkApplicationRelease fn');

try {
const currentInfo = JSON.parse(await promisedReadFile(getCorrectPath('src/releaseVersion.json')));
const currentInfo = JSON.parse(await promisedReadFile(getCorrectPath('config/releaseVersion.json')));
logger.info('current release version', currentInfo);
const latestInfo = await getApplicationRelease();
logger.info('latest application release version', latestInfo);
Expand Down
6 changes: 3 additions & 3 deletions src/utils/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = log.scope('env.js');

const isDevelopment = () => !app.isPackaged;

const getCorrectPath = targetPath => {
const getCorrectPath = (targetPath, customLevelPath) => {
logger.info('targetPath:', targetPath);
let returnPath = '';

Expand All @@ -23,9 +23,9 @@ const getCorrectPath = targetPath => {
returnPath = path.join(app.getAppPath(), targetPath);
} else if (isMacOS()) {
logger.info('system: macos');
returnPath = path.join(app.getAppPath(), '../../', targetPath);
returnPath = path.join(app.getAppPath(), customLevelPath || '../../', targetPath);
} else {
returnPath = path.join(app.getAppPath(), '../../', targetPath);
returnPath = path.join(app.getAppPath(), customLevelPath || '../../', targetPath);
}
logger.info('returnPath:', returnPath);
return returnPath;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/proxy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { promisedReadFile, promisedWriteFile } = require('./promisedFs');
const { getCorrectPath } = require('./env');

const proxyFilePath = getCorrectPath('src/proxy');
const proxyFilePath = getCorrectPath('config/proxy');

const setProxy = async proxyUrl => promisedWriteFile(proxyFilePath, proxyUrl);

Expand Down

0 comments on commit 150310c

Please sign in to comment.