Skip to content

Commit 775a6c5

Browse files
committed
upd
1 parent 3ad5a43 commit 775a6c5

File tree

5 files changed

+35
-29
lines changed

5 files changed

+35
-29
lines changed

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@
7575
"test-umdbrowser": "npm run build-browser-umd && karma start karma.umd.conf.js --single-run",
7676
"test-karma-local": "karma start karma.local_chrome.bs.conf.js && npm run build-browser-umd && karma start karma.local_chrome.umd.conf.js",
7777
"prebuild": "npm run clean",
78-
"compile": "tsc -p tsconfig.build.json",
79-
"build": "npm run validate-platform-isolation && npm run genmsg && npm run compile && rollup -c rollup.config.new.js && cp dist/index.browser.d.ts dist/index.d.ts",
80-
"build:win": "tsc --noEmit && npm run genmsg && npm run compile && rollup -c rollup.config.new.js && type nul > dist/optimizely.lite.es.d.ts && type nul > dist/optimizely.lite.es.min.d.ts && type nul > dist/optimizely.lite.min.d.ts",
81-
"build-browser-umd": "npm run compile && rollup -c rollup.config.new.js --config-umd",
78+
"build": "npm run validate-platform-isolation && npm run genmsg && tsc && rollup -c rollup.config.mjs && cp dist/index.browser.d.ts dist/index.d.ts",
79+
"build:win": "npm run validate-platform-isolation && npm run genmsg && tsc && rollup -c rollup.config.mjs && copy dist\\index.browser.d.ts dist\\index.d.ts",
80+
"build-browser-umd": "tsc && rollup -c rollup.config.mjs --config-umd",
8281
"coveralls": "nyc --reporter=lcov npm test",
8382
"prepare": "npm run build",
8483
"prepublishOnly": "npm test",
85-
"postbuild:win": "@powershell copy \"dist/index.lite.d.ts\" \"dist/optimizely.lite.es.d.ts\" && @powershell copy \"dist/index.lite.d.ts\" \"dist/optimizely.lite.es.min.d.ts\" && @powershell copy \"dist/index.lite.d.ts\" \"dist/optimizely.lite.min.d.ts\"",
8684
"genmsg": "jiti message_generator ./lib/message/error_message.ts ./lib/message/log_message.ts",
8785
"ts-example": "node ./scripts/run-ts-example.js"
8886
},

scripts/run-ts-example.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,28 @@ function startDatafileServer() {
4747
return new Promise((resolve) => setTimeout(resolve, 1000));
4848
}
4949

50-
function cleanup() {
50+
async function cleanup() {
5151
if (datafileServer) {
5252
console.log('\n=== Stopping Datafile Server ===\n');
53-
datafileServer.kill();
54-
datafileServer = null;
53+
54+
return new Promise((resolve) => {
55+
const timeout = setTimeout(() => {
56+
console.log('Force killing datafile server...');
57+
datafileServer.kill('SIGKILL');
58+
resolve();
59+
}, 2000);
60+
61+
datafileServer.on('exit', () => {
62+
clearTimeout(timeout);
63+
datafileServer = null;
64+
resolve();
65+
});
66+
67+
datafileServer.kill('SIGTERM');
68+
});
5569
}
5670
}
5771

58-
// Handle cleanup on exit
59-
process.on('exit', cleanup);
60-
process.on('SIGINT', () => {
61-
cleanup();
62-
process.exit(0);
63-
});
64-
process.on('SIGTERM', () => {
65-
cleanup();
66-
process.exit(0);
67-
});
68-
6972
async function main() {
7073
console.log('=== Building SDK and Running TypeScript Example ===\n');
7174

@@ -89,12 +92,12 @@ async function main() {
8992
run('npm start', exampleDir);
9093

9194
// Cleanup and exit
92-
cleanup();
95+
await cleanup();
9396
console.log('\n=== Example completed successfully! ===\n');
9497
}
9598

96-
main().catch((error) => {
99+
main().catch(async (error) => {
97100
console.error('Error:', error);
98-
cleanup();
101+
await cleanup();
99102
process.exit(1);
100103
});

ts-example/datafile-server.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ server.listen(PORT, () => {
4949
});
5050

5151
// Handle graceful shutdown
52-
process.on('SIGINT', () => {
52+
const shutdown = () => {
5353
console.log('\n\nShutting down datafile server...');
5454
server.close(() => {
5555
console.log('Server stopped');
5656
process.exit(0);
5757
});
58-
});
58+
};
59+
60+
process.on('SIGINT', shutdown);
61+
process.on('SIGTERM', shutdown);

ts-example/package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ts-example/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ async function main(): Promise<void> {
194194
try {
195195
await testStaticConfigSetup();
196196
await testPollingConfigSetup();
197+
process.exit(0);
197198
} catch (error) {
198199
console.error('Error running tests:', error);
199200
process.exit(1);

0 commit comments

Comments
 (0)