Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules/
ignore
.vscode
test/remote
!test/test2/node_modules

playground
.DS_Store
Expand Down
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ npm install --save-dev ftp-deploy
## Usage

The most basic usage:

```js
var FtpDeploy = require("ftp-deploy");
var ftpDeploy = new FtpDeploy();
Expand All @@ -28,7 +29,12 @@ var config = {
// include: ["*", "**/*"], // this would upload everything except dot files
include: ["*.php", "dist/*", ".*"],
// e.g. exclude sourcemaps, and ALL files in node_modules (including dot files)
exclude: ["dist/**/*.map", "node_modules/**", "node_modules/**/.*", ".git/**"],
exclude: [
"dist/**/*.map",
"node_modules/**",
"node_modules/**/.*",
".git/**"
],
// delete ALL existing files at destination before uploading, if true
deleteRemote: false,
// Passive mode is forced (EPSV command is not sent)
Expand All @@ -48,10 +54,11 @@ ftpDeploy.deploy(config, function(err, res) {
});
```

**Note:**
- in version 2 the config file expects a field of `user` rather than `username` in 1.x.
- The config file is passed as-is to Promise-FTP.
- I create a file - e.g. deploy.js - in the root of my source code and add a script to its `package.json` so that I can `npm run deploy`.
**Note:**

- in version 2 the config file expects a field of `user` rather than `username` in 1.x.
- The config file is passed as-is to Promise-FTP.
- I create a file - e.g. deploy.js - in the root of my source code and add a script to its `package.json` so that I can `npm run deploy`.

```json
"scripts": {
Expand All @@ -68,7 +75,7 @@ These are lists of [minimatch globs](https://github.com/isaacs/minimatch). ftp-d

## Events

ftp-deploy reports to clients using events. To get the output you need to implement watchers for "uploading", "uploaded" and "log":
ftp-deploy reports to clients using events. To get the output you need to implement watchers for "uploading", "uploaded" and "log":

```js
ftpDeploy.on("uploading", function(data) {
Expand Down Expand Up @@ -105,6 +112,5 @@ npm test

## ToDo

- re-enable continueOnError
- update newer files only (PR welcome)

- re-enable continueOnError
- update newer files only (PR welcome)
15 changes: 9 additions & 6 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@ function getPassword(config) {
}
}

// Analysing local firstory

// Analysing local directory
function canIncludePath(includes, excludes, filePath) {
let go = (acc, item) =>
acc || minimatch(filePath, item, { matchBase: true });
const options = { matchBase: true };
let go = (acc, item) => acc || minimatch(filePath, item, options);
let canInclude = includes.reduce(go, false);

// Now check whether the file should in fact be specifically excluded
if (canInclude) {
// if any excludes match return false
if (excludes) {
let go2 = (acc, item) =>
acc && !minimatch(filePath, item, { matchBase: true });
let go2 = (acc, exclItem) => {
const val = minimatch(filePath, exclItem, options);
// console.log(`minimatch("${filePath}", "${exclItem}", { matchBase: true })`, val);
return acc && !val;
};
canInclude = excludes.reduce(go2, true);
}
}
Expand Down Expand Up @@ -133,6 +135,7 @@ mkDirExists = (ftp, dir) => {
// Make the directory using recursive expand
return ftp.mkdir(dir, true).catch(err => {
if (err.message.startsWith("EEXIST")) {
// Ignore an error that the directory already exists
return Promise.resolve();
} else {
console.log("[mkDirExists]", err.message);
Expand Down
5 changes: 5 additions & 0 deletions src/lib.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ describe("dirParseSync", () => {
exp2
);
});
it('should be able to exclude node_modules', () => {
const rootDir = path.join(__dirname, '../test/test2');
let exp = {'/': ['includeme.txt']};
assert.deepEqual(lib.parseLocal(['*'], ['node_modules/**'], rootDir, '/'), exp);
});
});

let exp = {
Expand Down
Empty file added test/test2/includeme.txt
Empty file.
1 change: 1 addition & 0 deletions test/test2/node_modules/local/.excludedFile.txt

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

Empty file.
1 change: 1 addition & 0 deletions test/test2/node_modules/local/folderA/test-inside-a.txt

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

1 change: 1 addition & 0 deletions test/test2/node_modules/local/test-inside-root.txt

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