Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change root directory name #171

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 92 additions & 63 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
"minimatch": "9.0.0",
"promise-ftp": "^1.3.5",
"read": "^2.1.0",
"ssh2-sftp-client": "^7.2.1",
"ssh2-sftp-client": "^11.0.0",
"upath": "^2.0.1"
},
"devDependencies": {
"chai": "^4.3.7",
"delete": "^1.1.0",
"dotenv": "^16.4.5",
"ftp-srv": "^4.6.2",
"mocha": "^9.1.3"
},
Expand Down
17 changes: 11 additions & 6 deletions src/ftp-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,22 @@ const FtpDeployer = function () {
// console.log("newDirectory", newDirectory);
return lib.mapSeries(fnames, (fname) => {
let tmpFileName = upath.join(config.localRoot, relDir, fname);
let tmp = fs.readFileSync(tmpFileName);
// read file as Buffer
let tmpFileContents = fs.readFileSync(tmpFileName);
this.eventObject["filename"] = upath.join(relDir, fname);

this.emit("uploading", this.eventObject);
const putPath = upath.join(config.remoteRoot, relDir, fname);

return this.ftp
.put(tmp, upath.join(config.remoteRoot, relDir, fname))
.put(tmpFileContents, putPath)
.then(() => {
this.eventObject.transferredFileCount++;
this.emit("uploaded", this.eventObject);
return Promise.resolve("uploaded " + tmpFileName);
})
.catch((err) => {
this.eventObject["error"] = err;
this.eventObject["error"] = err.message;
this.emit("upload-error", this.eventObject);
// if continue on error....
return Promise.reject(err);
Expand All @@ -89,8 +91,11 @@ const FtpDeployer = function () {
return this.ftp
.connect(config)
.then((serverMessage) => {
this.emit("log", "Connected to: " + config.host);
this.emit("log", "Connected: Server message: " + serverMessage);
// ftp returns the servr messsage, but sftp does not!
this.emit(
"log",
"Connected to: " + config.host + " " + serverMessage || ""
);

// sftp does not provide a connection status
// so instead provide one ourself
Expand Down Expand Up @@ -127,7 +132,7 @@ const FtpDeployer = function () {
config.include,
config.exclude,
config.localRoot,
"/"
"./"
);
// console.log(filemap);
this.emit(
Expand Down