From 398d0f6957877a9e69036ac02fe77fb97ff5dbd7 Mon Sep 17 00:00:00 2001 From: Simon C Date: Wed, 6 Mar 2024 14:43:32 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Ajout=20de=20la=20case=20=C3=A0=20coche?= =?UTF-8?q?r=20pour=20l'environement=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 6 ++++-- scripts/fetchData.js | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9c0aea4..dacbd13 100644 --- a/.drone.yml +++ b/.drone.yml @@ -62,6 +62,8 @@ steps: - npm run fetchData - npm run lint - npm run build + environment: + NODE_ENV: 'production' - name: deploy on s3 image: minio/mc @@ -152,8 +154,8 @@ steps: - npm run fetchData - npm run lint - npm run build - - apk add --no-cache jq - - echo $(cat src/data.json | jq -c '[.[0]]') > src/data.json + environment: + NODE_ENV: 'test' - name: deploy on s3 image: minio/mc diff --git a/scripts/fetchData.js b/scripts/fetchData.js index 361b88c..8167f9e 100644 --- a/scripts/fetchData.js +++ b/scripts/fetchData.js @@ -48,9 +48,12 @@ async function fetchScoresData() { .map((item) => `fields[]=${item}`) .join("&")}`; let scores = (await fetchJSONApi(url)).data; - if (process.env.NODE_ENV != "staging") { + if (process.env.NODE_ENV == "production") { console.log("Suppresion des scores avec le mode brouillon en production"); scores = scores.filter((score) => !score.draft); + } else if (process.env.NODE_ENV == "test") { + console.log("Suppresion des scores sans l'environnement test"); + scores = scores.filter((score) => score.env_test); } await fs.writeFile("./src/data.json", JSON.stringify(scores), "utf8");