Expected Behavior
When you run a Windows installer (built with NSIS) to install a new version of your CLI over the top of an old one, it uninstalls the previous version first, so that files that are obsolete in the new version won't be left behind.
Actual Behavior
The previous version is not uninstalled and old files are retained, potentially causing unexpected application behavior.
Example
Suppose that version 1 of your application has a command that looks like this:
src/commands/hello.js
const { Command } = require('@oclif/command');
const sayHello = require('../hello');
class HelloCommand extends Command {
async run() {
sayHello();
}
}
HelloCommand.description = 'Says hello';
module.exports = HelloCommand;
The HelloCommand class delegates the actual execution of the command to another module, src/hello.js:
src/hello.js
module.exports = () => {
console.log('Hello, old world!');
};
After people have installed the application, you decide to refactor src/hello.js under a src/hello directory. (In a real world scenario, you might be doing this because the original module has become too complex and you want to break it apart.) So you delete src/hello.js and create this file instead:
src/hello/index.js
module.exports = () => {
console.log('Hello, new world!');
};
When you run the hello command, it prints out Hello, new world! as expected, so you build and deploy new installers. However, when people install the new Windows version over the top of an existing installation, the old src/hello.js file does not get deleted. Now the installed application has both src/hello.js and src/hello/index.js, but src/hello.js takes priority on the require(), so when people run it, they get Hello, old world! instead of Hello, new world!.
Expected Behavior
When you run a Windows installer (built with NSIS) to install a new version of your CLI over the top of an old one, it uninstalls the previous version first, so that files that are obsolete in the new version won't be left behind.
Actual Behavior
The previous version is not uninstalled and old files are retained, potentially causing unexpected application behavior.
Example
Suppose that version 1 of your application has a command that looks like this:
src/commands/hello.js
The
HelloCommandclass delegates the actual execution of the command to another module,src/hello.js:src/hello.js
After people have installed the application, you decide to refactor
src/hello.jsunder asrc/hellodirectory. (In a real world scenario, you might be doing this because the original module has become too complex and you want to break it apart.) So you deletesrc/hello.jsand create this file instead:src/hello/index.js
When you run the
hellocommand, it prints outHello, new world!as expected, so you build and deploy new installers. However, when people install the new Windows version over the top of an existing installation, the oldsrc/hello.jsfile does not get deleted. Now the installed application has bothsrc/hello.jsandsrc/hello/index.js, butsrc/hello.jstakes priority on therequire(), so when people run it, they getHello, old world!instead ofHello, new world!.