Skip to content
This repository was archived by the owner on Apr 21, 2022. It is now read-only.
This repository was archived by the owner on Apr 21, 2022. It is now read-only.

NSIS install over the top of previous version doesn't delete old files #404

@rjwut-chg

Description

@rjwut-chg

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!.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions