fix: checking process.env.NODE_ENV
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
d672385776
commit
18bb8a4ea5
|
@ -37,7 +37,7 @@ module.exports = Self => {
|
|||
if (!recipient)
|
||||
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
|
||||
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
if (!Self.app.models.Application.isProduction())
|
||||
message = `[Test:Environment to user ${userId}] ` + message;
|
||||
|
||||
const chat = await models.Chat.create({
|
||||
|
|
|
@ -94,7 +94,7 @@ module.exports = Self => {
|
|||
* @return {Promise} - The request promise
|
||||
*/
|
||||
Self.sendMessage = async function sendMessage(senderFk, recipient, message) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!Self.app.models.Application.isProduction()) {
|
||||
return new Promise(resolve => {
|
||||
return resolve({
|
||||
statusCode: 200,
|
||||
|
@ -149,7 +149,7 @@ module.exports = Self => {
|
|||
* @return {Promise} - The request promise
|
||||
*/
|
||||
Self.getUserStatus = async function getUserStatus(username) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!Self.app.models.Application.isProduction()) {
|
||||
return new Promise(resolve => {
|
||||
return resolve({
|
||||
data: {
|
||||
|
|
|
@ -22,7 +22,7 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
if (!Self.app.models.Application.isProduction())
|
||||
throw new UserError(`Action not allowed on the test environment`);
|
||||
|
||||
const models = Self.app.models;
|
||||
|
|
|
@ -119,7 +119,7 @@ module.exports = Self => {
|
|||
]
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV != 'production')
|
||||
if (!Self.app.models.Application.isProduction(false))
|
||||
throw new UserError('Action not allowed on the test environment');
|
||||
|
||||
// delete old
|
||||
|
|
|
@ -43,8 +43,7 @@ module.exports = Self => {
|
|||
Self.scrub = async function(collection, remove, limit, dryRun, skipLock) {
|
||||
const $ = Self.app.models;
|
||||
|
||||
const env = process.env.NODE_ENV;
|
||||
dryRun = dryRun || (env && env !== 'production');
|
||||
dryRun = dryRun || !Self.app.models.Application.isProduction(false);
|
||||
|
||||
const instance = await $.ImageCollection.findOne({
|
||||
fields: ['id'],
|
||||
|
|
|
@ -41,7 +41,7 @@ module.exports = Self => {
|
|||
if (!hasWriteRole)
|
||||
throw new UserError(`You don't have enough privileges`);
|
||||
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
if (!Self.app.models.Application.isProduction())
|
||||
throw new UserError(`Action not allowed on the test environment`);
|
||||
|
||||
// Upload file to temporary path
|
||||
|
|
|
@ -70,7 +70,7 @@ module.exports = Self => {
|
|||
const newParams = Object.assign({}, queueParams, sendParams);
|
||||
const email = new Email(queueName, newParams);
|
||||
|
||||
if (process.env.NODE_ENV != 'test')
|
||||
if (Self.app.models.Application.isProduction())
|
||||
await email.send();
|
||||
|
||||
await queue.updateAttribute('status', statusSent);
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (localAsProduction = true) => {
|
||||
if ((!process.env.NODE_ENV && localAsProduction) || process.env.NODE_ENV == 'production') return true;
|
||||
};
|
|
@ -1,3 +1,4 @@
|
|||
const isProductionFn = require('../methods/application/isProduction');
|
||||
|
||||
module.exports = function(Self) {
|
||||
require('../methods/application/status')(Self);
|
||||
|
@ -6,4 +7,8 @@ module.exports = function(Self) {
|
|||
require('../methods/application/executeProc')(Self);
|
||||
require('../methods/application/executeFunc')(Self);
|
||||
require('../methods/application/getEnumValues')(Self);
|
||||
|
||||
Self.isProduction = (localAsProduction = true) => {
|
||||
return isProductionFn(localAsProduction);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,9 +3,10 @@ const app = require('vn-loopback/server/server');
|
|||
const ldap = require('../util/ldapjs-extra');
|
||||
const crypto = require('crypto');
|
||||
const nthash = require('smbhash').nthash;
|
||||
const isProduction = require('vn-loopback/common/methods/application/isProduction');
|
||||
|
||||
module.exports = Self => {
|
||||
const shouldSync = process.env.NODE_ENV !== 'test';
|
||||
const shouldSync = isProduction();
|
||||
|
||||
Self.getLinker = async function() {
|
||||
return await Self.findOne({
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
const ldap = require('../util/ldapjs-extra');
|
||||
const execFile = require('child_process').execFile;
|
||||
const isProduction = require('vn-loopback/common/methods/application/isProduction');
|
||||
|
||||
/**
|
||||
* Summary of userAccountControl flags:
|
||||
|
@ -12,7 +13,7 @@ const UserAccountControlFlags = {
|
|||
};
|
||||
|
||||
module.exports = Self => {
|
||||
const shouldSync = process.env.NODE_ENV !== 'test';
|
||||
const shouldSync = isProduction();
|
||||
|
||||
Self.getLinker = async function() {
|
||||
return await Self.findOne({
|
||||
|
|
|
@ -47,7 +47,7 @@ module.exports = Self => {
|
|||
|
||||
let response;
|
||||
try {
|
||||
if (process.env.NODE_ENV !== 'production')
|
||||
if (!Self.app.models.Application.isProduction(false))
|
||||
response = {result: [{status: 'ok'}]};
|
||||
else {
|
||||
const jsonTest = {
|
||||
|
|
|
@ -66,7 +66,7 @@ module.exports = Self => {
|
|||
console.error(err);
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV == 'test') {
|
||||
if (!Self.app.models.Application.isProduction()) {
|
||||
try {
|
||||
await fs.access(file.path);
|
||||
} catch (error) {
|
||||
|
|
|
@ -59,7 +59,7 @@ module.exports = Self => {
|
|||
hasPdf: true
|
||||
}, options);
|
||||
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
if (Self.app.models.Application.isProduction()) {
|
||||
await print.storage.write(buffer, {
|
||||
type: 'invoice',
|
||||
path: pdfFile.path,
|
||||
|
|
|
@ -111,7 +111,7 @@ module.exports = Self => {
|
|||
const destinationFile = path.join(
|
||||
accessContainer.client.root, accessContainer.name, appName, `${toVersion}.7z`);
|
||||
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
if (!Self.app.models.Application.isProduction())
|
||||
await fs.unlink(srcFile);
|
||||
else {
|
||||
await fs.move(srcFile, destinationFile, {
|
||||
|
|
Loading…
Reference in New Issue