Skip to content

Commit

Permalink
fix(compiler): destroy callback naming (#3289)
Browse files Browse the repository at this point in the history
Fix Typos for `addDestroy` (`addDestory`) and `removeDestroy` (`removeDestory`)

BREAKING CHANGE: Public APIs `addDestroy` (`addDestory`) and `removeDestroy`
(`removeDestory`) have been renamed to fix typos
  • Loading branch information
sean-perkins authored and rwaskiewicz committed Jan 25, 2023
1 parent 3d16b41 commit 602b322
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/compiler/build/watch-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const createWatchBuild = async (
}
};

config.sys.addDestory(close);
config.sys.addDestroy(close);

return {
start,
Expand Down
16 changes: 8 additions & 8 deletions src/compiler/sys/stencil-sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const createSystem = (c?: { logger?: Logger }): CompilerSystem => {
const items = new Map<string, FsItem>();
const destroys = new Set<() => Promise<void> | void>();

const addDestory = (cb: () => void) => destroys.add(cb);
const removeDestory = (cb: () => void) => destroys.delete(cb);
const addDestroy = (cb: () => void) => destroys.add(cb);
const removeDestroy = (cb: () => void) => destroys.delete(cb);
const events = buildEvents();
const hardwareConcurrency = (IS_BROWSER_ENV && navigator.hardwareConcurrency) || 1;

Expand Down Expand Up @@ -407,7 +407,7 @@ export const createSystem = (c?: { logger?: Logger }): CompilerSystem => {
}
};

addDestory(close);
addDestroy(close);

if (item) {
item.isDirectory = true;
Expand All @@ -427,7 +427,7 @@ export const createSystem = (c?: { logger?: Logger }): CompilerSystem => {

return {
close() {
removeDestory(close);
removeDestroy(close);
close();
},
};
Expand All @@ -447,7 +447,7 @@ export const createSystem = (c?: { logger?: Logger }): CompilerSystem => {
}
};

addDestory(close);
addDestroy(close);

if (item) {
item.isDirectory = false;
Expand All @@ -467,7 +467,7 @@ export const createSystem = (c?: { logger?: Logger }): CompilerSystem => {

return {
close() {
removeDestory(close);
removeDestroy(close);
close();
},
};
Expand Down Expand Up @@ -586,7 +586,7 @@ export const createSystem = (c?: { logger?: Logger }): CompilerSystem => {
events,
access,
accessSync,
addDestory,
addDestroy,
copyFile,
createDir,
createDirSync,
Expand All @@ -611,7 +611,7 @@ export const createSystem = (c?: { logger?: Logger }): CompilerSystem => {
readFileSync,
realpath,
realpathSync,
removeDestory,
removeDestroy,
rename,
fetch,
resolvePath,
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/sys/worker/sys-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const createSysWorker = (config: ValidatedConfig) => {
) {
const workerCtrl = config.sys.createWorkerController(config.maxConcurrentWorkers);

config.sys.addDestory(() => workerCtrl.destroy());
config.sys.addDestroy(() => workerCtrl.destroy());

config.logger.debug(`create workers, maxWorkers: ${workerCtrl.maxWorkers}`);
return createWorkerMainContext(workerCtrl);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transpile/create-build-program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const createTsBuildProgram = async (
},
};

config.sys.addDestory(() => tsWatchSys.clearTimeout(currentBuildTimeoutId));
config.sys.addDestroy(() => tsWatchSys.clearTimeout(currentBuildTimeoutId));

/**
* Create a {@link ts.WatchCompilerHost}. A CompilerHost allows a {@link ts.Program} to interact with the
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transpile/create-watch-program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const createTsWatchProgram = async (
},
};

config.sys.addDestory(() => tsWatchSys.clearTimeout(timeoutId));
config.sys.addDestroy(() => tsWatchSys.clearTimeout(timeoutId));

const tsWatchHost = ts.createWatchCompilerHost(
config.tsconfig,
Expand Down
4 changes: 2 additions & 2 deletions src/declarations/stencil-public-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ export interface CompilerSystem {
/**
* Add a callback which will be ran when destroy() is called.
*/
addDestory(cb: () => void): void;
addDestroy(cb: () => void): void;
/**
* Always returns a boolean, does not throw.
*/
Expand Down Expand Up @@ -1063,7 +1063,7 @@ export interface CompilerSystem {
/**
* Remove a callback which will be ran when destroy() is called.
*/
removeDestory(cb: () => void): void;
removeDestroy(cb: () => void): void;
/**
* Rename old path to new path. Does not throw.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/sys/node/node-sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ export function createNodeSys(c: { process?: any } = {}): CompilerSystem {
} catch (e) {}
return hasAccess;
},
addDestory(cb) {
addDestroy(cb) {
destroys.add(cb);
},
removeDestory(cb) {
removeDestroy(cb) {
destroys.delete(cb);
},
applyPrerenderGlobalPatch(opts) {
Expand Down Expand Up @@ -453,11 +453,11 @@ export function createNodeSys(c: { process?: any } = {}): CompilerSystem {
tsFileWatcher.close();
};

sys.addDestory(close);
sys.addDestroy(close);

return {
close() {
sys.removeDestory(close);
sys.removeDestroy(close);
tsFileWatcher.close();
},
};
Expand All @@ -481,11 +481,11 @@ export function createNodeSys(c: { process?: any } = {}): CompilerSystem {
const close = () => {
tsFileWatcher.close();
};
sys.addDestory(close);
sys.addDestroy(close);

return {
close() {
sys.removeDestory(close);
sys.removeDestroy(close);
tsFileWatcher.close();
},
};
Expand Down

0 comments on commit 602b322

Please sign in to comment.