la-haute-societe / ssh-deploy-release

Deploy releases over SSH with rsync, archive ZIP / TAR, symlinks, SCP ...
https://www.npmjs.com/package/ssh-deploy-release
MIT License
36 stars 10 forks source link

Decompress not working #2

Closed ghost closed 7 years ago

ghost commented 7 years ago

The decompressArchiveOnRemoteTask does not work on my configuration. The "cd " + this.release.path command doesn't work so any of the following commands are performed on the root shell login. When I modify your code to use absolute paths for the untarring, just like you do with the rm, it's working perfectly. The server I am deploying to is an ubuntu 16.04. Maybe it is OS specific.

maxime-colin commented 7 years ago

Thanks to share this issue. Could you please provide a pull request or paste the code you modified?

ghost commented 7 years ago

It's just a small fix, so I will provide the code of the modified func here. I changed relative paths to absolute paths.

decompressArchiveOnRemoteTask(done) { if (this.options.mode != 'archive') { done(); return; }

    this.logger.subhead('Decompress archive on remote');
    let spinner = this.logger.startSpinner('Decompressing');

    const archivePath = path.posix.join(this.release.path, this.options.archiveName);
    const untarMap = {
        'zip': "unzip -q " + archivePath + " -d " + this.release.path + "/",
        'tar': "tar -xvf " + archivePath + " -C " + this.release.path + "/",
    };

    // Check archiveType is supported
    if (!untarMap[this.options.archiveType]) {
        logger.fatal(this.options.archiveType + ' not supported.');
    }

    const command = [
        untarMap[this.options.archiveType],
        "rm " + archivePath,
    ].join('\n');

    this.remote.exec(command, () => {
        spinner.stop();
        this.logger.ok('Done');
        done();
    });
}
maxime-colin commented 7 years ago

I have just deployed a version 2.1.1 on npm with this fix. Thanks @verrydtj