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 Mar 28, 2022
1 parent 687eb00 commit b733e79
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 @@ -143,7 +143,7 @@ export const createWatchBuild = async (config: d.Config, compilerCtx: d.Compiler
}
};

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 @@ -31,8 +31,8 @@ export const createSystem = (c?: { logger?: Logger }) => {
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 @@ -394,7 +394,7 @@ export const createSystem = (c?: { logger?: Logger }) => {
}
};

addDestory(close);
addDestroy(close);

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

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

addDestory(close);
addDestroy(close);

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

return {
close() {
removeDestory(close);
removeDestroy(close);
close();
},
};
Expand Down Expand Up @@ -573,7 +573,7 @@ export const createSystem = (c?: { logger?: Logger }) => {
events,
access,
accessSync,
addDestory,
addDestroy,
copyFile,
createDir,
createDirSync,
Expand All @@ -598,7 +598,7 @@ export const createSystem = (c?: { logger?: Logger }) => {
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 @@ -11,7 +11,7 @@ export const createSysWorker = (config: Config) => {
) {
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 @@ -43,7 +43,7 @@ export const createTsBuildProgram = async (
},
};

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

const tsWatchHost = ts.createWatchCompilerHost(
config.tsconfig,
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 @@ -33,7 +33,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 @@ -894,7 +894,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 @@ -1036,7 +1036,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 @@ -66,10 +66,10 @@ export function createNodeSys(c: { process?: any } = {}) {
} catch (e) {}
return hasAccess;
},
addDestory(cb) {
addDestroy(cb) {
destroys.add(cb);
},
removeDestory(cb) {
removeDestroy(cb) {
destroys.delete(cb);
},
applyPrerenderGlobalPatch(opts) {
Expand Down Expand Up @@ -443,11 +443,11 @@ export function createNodeSys(c: { process?: any } = {}) {
tsFileWatcher.close();
};

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

return {
close() {
sys.removeDestory(close);
sys.removeDestroy(close);
tsFileWatcher.close();
},
};
Expand All @@ -471,11 +471,11 @@ export function createNodeSys(c: { process?: any } = {}) {
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 b733e79

Please sign in to comment.