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