jvcs 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/controllers/add.js +13 -3
  2. package/package.json +1 -1
@@ -22,7 +22,7 @@ async function loadIgnorePatterns() {
22
22
  return content.split("\n").map(line => line.trim()).filter(line => line.length > 0 && !line.startsWith("#"))
23
23
  }
24
24
 
25
- function isIgnored(relativePath, ignorePatterns) {
25
+ function isIgnored(relativePath, ignorePatterns = []) {
26
26
  return ignorePatterns.some(pattern =>
27
27
  minimatch(relativePath, pattern, { dot: true })
28
28
  )
@@ -100,7 +100,7 @@ async function addCmd(paths) {
100
100
  let targets = []
101
101
  if(paths.length === 1 && paths[0] === ".") {
102
102
  let rootEntries = await fs.readdir(process.cwd(),{withFileTypes: true})
103
- targets = rootEntries.filter((target)=> target.name !== ".jvcs").map((item)=> path.resolve(process.cwd(), item.name))
103
+ targets = rootEntries.filter((target)=> target.name !== ".jvcs" && target.name !== ".jvcsignore").map((item)=> path.resolve(process.cwd(), item.name))
104
104
  }
105
105
  else {
106
106
  targets = paths.map((p)=> path.resolve(process.cwd(),p))
@@ -117,6 +117,16 @@ async function addCmd(paths) {
117
117
  }
118
118
 
119
119
  const relative = path.relative(process.cwd(), target)
120
+ if (relative === ".jvcs" || relative.startsWith(".jvcs" + path.sep)) {
121
+ console.log(chalk.red(`Cannot add internal repository folder ".jvcs"`))
122
+ continue
123
+ }
124
+
125
+ if (relative === ".jvcsignore") {
126
+ console.log(chalk.red(`Cannot add ".jvcsignore" file`))
127
+ continue
128
+ }
129
+
120
130
  if(isIgnored(relative, ignorePatterns)) {
121
131
  console.log(chalk.gray(`skipped "${relative}" as it is present in .jvcsignore`))
122
132
  continue
@@ -138,7 +148,7 @@ async function addCmd(paths) {
138
148
  }
139
149
  else if(stats.isDirectory()) {
140
150
  await fs.cp(target,destination,{recursive: true})
141
- await hashDirectoryRecursive(target,hashData)
151
+ await hashDirectoryRecursive(target,hashData,ignorePatterns)
142
152
  console.log(chalk.cyan(`Added folder: ${path.relative(process.cwd(), target)}`));
143
153
  }
144
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jvcs",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "bin": {
5
5
  "jvcs": "index.js"
6
6
  },