Skip to content

Commit 96b834b

Browse files
committed
winget-source: support logging to file
1 parent a845682 commit 96b834b

File tree

5 files changed

+258
-23
lines changed

5 files changed

+258
-23
lines changed

winget-source/package-lock.json

Lines changed: 190 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

winget-source/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"async": "^3.2.4",
1111
"jszip": "^3.10.1",
1212
"node-fetch": "^3.3.0",
13-
"sqlite3": "^5.1.4"
13+
"sqlite3": "^5.1.4",
14+
"winston": "^3.8.2"
1415
},
1516
"scripts": {
1617
"start": "node sync-repo.js"

winget-source/sync-repo.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ import {
99
getLocalPath,
1010
makeTempDirectory,
1111
requireEnvironmentVariables,
12+
setupWinstonLogger,
1213
syncFile
1314
} from './utilities.js'
1415

15-
const { debugMode, parallelLimit } = requireEnvironmentVariables();
16+
const { debugMode, logFile, parallelLimit, remote } = requireEnvironmentVariables();
17+
1618
const { Database } = debugMode ? sqlite3.verbose() : sqlite3;
19+
const logger = setupWinstonLogger(debugMode, logFile);
20+
21+
logger.info(`start syncing with ${remote}`);
1722

1823
syncFile('source.msix').then(async updated => {
1924
if (!updated) {
20-
console.info('nothing to update');
25+
logger.info('nothing to update');
2126
return;
2227
}
2328

@@ -33,9 +38,10 @@ syncFile('source.msix').then(async updated => {
3338
async.eachLimit(uris, parallelLimit, syncFile, (error) => {
3439
rm(temp, { recursive: true });
3540
if (error) {
36-
console.error(error);
41+
logger.error(error);
3742
process.exit(-1);
3843
}
44+
logger.info(`successfully synced with ${remote}`);
3945
});
4046
});
4147
});

winget-source/sync.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
set -e
1414

15-
[[ $DEBUG == true ]] && set -x
15+
if [[ $DEBUG = true ]]; then
16+
set -x
17+
else
18+
export NODE_ENV=production
19+
fi
1620

1721
exec node /sync-repo.js

0 commit comments

Comments
 (0)