velocious 1.0.58 → 1.0.60

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "velocious": "bin/velocious.js"
4
4
  },
5
5
  "name": "velocious",
6
- "version": "1.0.58",
6
+ "version": "1.0.60",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "test": "VELOCIOUS_TEST_DIR=../ cd spec/dummy && npx velocious test",
@@ -14,6 +14,7 @@ describe("Record - find", () => {
14
14
 
15
15
  expect(foundTask.readAttribute("name")).toEqual("Test task")
16
16
  expect(foundTask.readColumn("name")).toEqual("Test task")
17
+ expect(foundTask.hasName()).toBeTrue()
17
18
  })
18
19
  })
19
20
 
@@ -212,18 +212,31 @@ class VelociousDatabaseRecord {
212
212
 
213
213
  const camelizedColumnName = inflection.camelize(column.getName(), true)
214
214
  const camelizedColumnNameBigFirst = inflection.camelize(column.getName())
215
- const setterMethodName = `set${camelizedColumnNameBigFirst}`
216
215
 
217
216
  this._attributeNameToColumnName[camelizedColumnName] = column.getName()
218
217
  this._columnNameToAttributeName[column.getName()] = camelizedColumnName
219
218
 
220
- this.prototype[camelizedColumnName] = function () {
219
+ this.prototype[camelizedColumnName] = function() {
221
220
  return this.readAttribute(camelizedColumnName)
222
221
  }
223
222
 
224
- this.prototype[setterMethodName] = function (newValue) {
223
+ this.prototype[`set${camelizedColumnNameBigFirst}`] = function(newValue) {
225
224
  return this._setColumnAttribute(camelizedColumnName, newValue)
226
225
  }
226
+
227
+ this.prototype[`has${camelizedColumnNameBigFirst}`] = function() {
228
+ let value = this[camelizedColumnName]()
229
+
230
+ if (typeof value == "string") {
231
+ value = value.trim()
232
+ }
233
+
234
+ if (value) {
235
+ return true
236
+ }
237
+
238
+ return false
239
+ }
227
240
  }
228
241
 
229
242
  await this._defineTranslationMethods()
package/src/logger.js CHANGED
@@ -2,19 +2,31 @@ import Configuration from "./configuration.js"
2
2
 
3
3
  function consoleLog(message) {
4
4
  return new Promise((resolve) => {
5
- process.stdout.write(`${message}\n`, "utf8", resolve)
5
+ if (process.stdout) {
6
+ process.stdout.write(`${message}\n`, "utf8", resolve)
7
+ } else {
8
+ console.log(message)
9
+ }
6
10
  })
7
11
  }
8
12
 
9
13
  function consoleError(message) {
10
14
  return new Promise((resolve) => {
11
- process.stderr.write(`${message}\n`, "utf8", resolve)
15
+ if (process.stderr) {
16
+ process.stderr.write(`${message}\n`, "utf8", resolve)
17
+ } else {
18
+ console.error(message)
19
+ }
12
20
  })
13
21
  }
14
22
 
15
23
  function consoleWarn(message) {
16
24
  return new Promise((resolve) => {
17
- process.stderr.write(`${message}\n`, "utf8", resolve)
25
+ if (process.stderr) {
26
+ process.stderr.write(`${message}\n`, "utf8", resolve)
27
+ } else {
28
+ console.warn(message)
29
+ }
18
30
  })
19
31
  }
20
32