Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rphillips-cc committed Apr 17, 2024
1 parent d2cbe20 commit e622f58
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 40 deletions.
7 changes: 6 additions & 1 deletion src/helpers/commands.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
function addEchoCommand(memo, command) {
memo.push(`echo '$ ${command}'`, command);
return memo;
}

module.exports = {
addEchoCommand: (memo, command) => [...memo, `echo '$ ${command}'`, command]
addEchoCommand
};
2 changes: 1 addition & 1 deletion src/lib/eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function getInstallCommands(buildConfig) {
if (buildConfig.manage_plugin_manually) {
return [
'npm install'
];
].reduce(addEchoCommand, []);
}

const pluginTag = buildConfig.use_beta_plugin ? 'next' : 'latest';
Expand Down
112 changes: 74 additions & 38 deletions tests/eleventy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,40 @@ test('outputs with empty config', () => {
'echo \'$ npm install\'',
'npm install',

"echo '$ if [ -f eleventy.config.cjs ]; then export ELEVENTY_CONFIG=eleventy.config.cjs; fi'",
'if [ -f eleventy.config.cjs ]; then export ELEVENTY_CONFIG=eleventy.config.cjs; fi',
"echo '$ if [ -f eleventy.config.js ]; then export ELEVENTY_CONFIG=eleventy.config.js; fi'",
'if [ -f eleventy.config.js ]; then export ELEVENTY_CONFIG=eleventy.config.js; fi',
"echo '$ if [ -f .eleventy.js ]; then export ELEVENTY_CONFIG=.eleventy.js; fi'",
'if [ -f .eleventy.js ]; then export ELEVENTY_CONFIG=.eleventy.js; fi',
"echo '$ export ELEVENTY_CONFIG_DIR=`dirname $ELEVENTY_CONFIG`'",
'export ELEVENTY_CONFIG_DIR=`dirname $ELEVENTY_CONFIG`',
"echo '$ echo $ELEVENTY_CONFIG'",
'echo $ELEVENTY_CONFIG',
"echo '$ echo $ELEVENTY_CONFIG_DIR'",
'echo $ELEVENTY_CONFIG_DIR',
"echo '$ if [ -f $ELEVENTY_CONFIG ]; then mv $ELEVENTY_CONFIG \"$ELEVENTY_CONFIG_DIR/default-eleventy.config.js\"; fi'",
'if [ -f $ELEVENTY_CONFIG ]; then mv $ELEVENTY_CONFIG "$ELEVENTY_CONFIG_DIR/default-eleventy.config.js"; fi',
"echo '$ cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.js $ELEVENTY_CONFIG'",
'cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.js $ELEVENTY_CONFIG',
"export CC_ELEVENTY_VERSION=`npm list @11ty/eleventy | grep @11ty/eleventy | awk -F \"@\" '{print $NF}'`",
'if [[ -z "$CC_ELEVENTY_VERSION" ]]; then export CC_ELEVENTY_VERSION=unknown; fi',
// eslint-disable-next-line no-template-curly-in-string
'echo "[🏷@11ty/eleventy:${CC_ELEVENTY_VERSION}]"',
"echo '$ if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi'",
'if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi',
"echo '$ if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi'",
'if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi',
"echo '$ if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi'",
'if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi',
"echo '$ if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi'",
'if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi',
"echo '$ echo $CONFIG'",
'echo $CONFIG',
"echo '$ CONFIG_DIR=`dirname $CONFIG`'",
'CONFIG_DIR=`dirname $CONFIG`',
"echo '$ echo $CONFIG_DIR'",
'echo $CONFIG_DIR',
"echo '$ CONFIG_BASE=`basename $CONFIG`'",
'CONFIG_BASE=`basename $CONFIG`',
"echo '$ echo $CONFIG_BASE'",
'echo $CONFIG_BASE',
"echo '$ CONFIG_INJECTED=\"$CONFIG_DIR/inject-cloudcannon.config.cjs\"'",
'CONFIG_INJECTED="$CONFIG_DIR/inject-cloudcannon.config.cjs"',
"echo '$ echo $CONFIG_INJECTED'",
'echo $CONFIG_INJECTED',
"echo '$ export CC_ELEVENTY_CONFIG=\"$CONFIG_DIR/default-$CONFIG_BASE\"'",
'export CC_ELEVENTY_CONFIG="$CONFIG_DIR/default-$CONFIG_BASE"',
"echo '$ echo $CC_ELEVENTY_CONFIG'",
'echo $CC_ELEVENTY_CONFIG',
"echo '$ if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi'",
'if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi',
"echo '$ cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED'",
'cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED',

'echo "$ source .cloudcannon/prebuild"',
'if [ -f ".cloudcannon/prebuild" ]; then source .cloudcannon/prebuild; else echo "Not found."; fi',
Expand All @@ -42,8 +60,8 @@ test('outputs with empty config', () => {
// eslint-disable-next-line no-template-curly-in-string
'echo "[🏷node:${DETECTED_NODE_VERSION}]"',

'echo \'$ npx @11ty/eleventy --output _site\'',
'npx @11ty/eleventy --output _site',
'echo \'$ npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site\'',
'npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site',

'echo "$ source .cloudcannon/postbuild"',
'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi',
Expand Down Expand Up @@ -78,22 +96,40 @@ test('outputs with @next config', () => {
'echo \'$ npm install\'',
'npm install',

"echo '$ if [ -f eleventy.config.cjs ]; then export ELEVENTY_CONFIG=eleventy.config.cjs; fi'",
'if [ -f eleventy.config.cjs ]; then export ELEVENTY_CONFIG=eleventy.config.cjs; fi',
"echo '$ if [ -f eleventy.config.js ]; then export ELEVENTY_CONFIG=eleventy.config.js; fi'",
'if [ -f eleventy.config.js ]; then export ELEVENTY_CONFIG=eleventy.config.js; fi',
"echo '$ if [ -f .eleventy.js ]; then export ELEVENTY_CONFIG=.eleventy.js; fi'",
'if [ -f .eleventy.js ]; then export ELEVENTY_CONFIG=.eleventy.js; fi',
"echo '$ export ELEVENTY_CONFIG_DIR=`dirname $ELEVENTY_CONFIG`'",
'export ELEVENTY_CONFIG_DIR=`dirname $ELEVENTY_CONFIG`',
"echo '$ echo $ELEVENTY_CONFIG'",
'echo $ELEVENTY_CONFIG',
"echo '$ echo $ELEVENTY_CONFIG_DIR'",
'echo $ELEVENTY_CONFIG_DIR',
"echo '$ if [ -f $ELEVENTY_CONFIG ]; then mv $ELEVENTY_CONFIG \"$ELEVENTY_CONFIG_DIR/default-eleventy.config.js\"; fi'",
'if [ -f $ELEVENTY_CONFIG ]; then mv $ELEVENTY_CONFIG "$ELEVENTY_CONFIG_DIR/default-eleventy.config.js"; fi',
"echo '$ cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.js $ELEVENTY_CONFIG'",
'cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.js $ELEVENTY_CONFIG',
"export CC_ELEVENTY_VERSION=`npm list @11ty/eleventy | grep @11ty/eleventy | awk -F \"@\" '{print $NF}'`",
'if [[ -z "$CC_ELEVENTY_VERSION" ]]; then export CC_ELEVENTY_VERSION=unknown; fi',
// eslint-disable-next-line no-template-curly-in-string
'echo "[🏷@11ty/eleventy:${CC_ELEVENTY_VERSION}]"',
"echo '$ if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi'",
'if [ -f eleventy.config.cjs ]; then CONFIG=eleventy.config.cjs; fi',
"echo '$ if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi'",
'if [ -f eleventy.config.mjs ]; then CONFIG=eleventy.config.mjs; fi',
"echo '$ if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi'",
'if [ -f eleventy.config.js ]; then CONFIG=eleventy.config.js; fi',
"echo '$ if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi'",
'if [ -f .eleventy.js ]; then CONFIG=.eleventy.js; fi',
"echo '$ echo $CONFIG'",
'echo $CONFIG',
"echo '$ CONFIG_DIR=`dirname $CONFIG`'",
'CONFIG_DIR=`dirname $CONFIG`',
"echo '$ echo $CONFIG_DIR'",
'echo $CONFIG_DIR',
"echo '$ CONFIG_BASE=`basename $CONFIG`'",
'CONFIG_BASE=`basename $CONFIG`',
"echo '$ echo $CONFIG_BASE'",
'echo $CONFIG_BASE',
"echo '$ CONFIG_INJECTED=\"$CONFIG_DIR/inject-cloudcannon.config.cjs\"'",
'CONFIG_INJECTED="$CONFIG_DIR/inject-cloudcannon.config.cjs"',
"echo '$ echo $CONFIG_INJECTED'",
'echo $CONFIG_INJECTED',
"echo '$ export CC_ELEVENTY_CONFIG=\"$CONFIG_DIR/default-$CONFIG_BASE\"'",
'export CC_ELEVENTY_CONFIG="$CONFIG_DIR/default-$CONFIG_BASE"',
"echo '$ echo $CC_ELEVENTY_CONFIG'",
'echo $CC_ELEVENTY_CONFIG',
"echo '$ if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi'",
'if [ -f $CONFIG ]; then mv $CONFIG $CC_ELEVENTY_CONFIG; fi',
"echo '$ cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED'",
'cp node_modules/eleventy-plugin-cloudcannon/src/inject-cloudcannon.config.cjs $CONFIG_INJECTED',

'echo \'$ export CC_ELEVENTY_INPUT="src"\'',
'export CC_ELEVENTY_INPUT="src"',
Expand All @@ -110,8 +146,8 @@ test('outputs with @next config', () => {
// eslint-disable-next-line no-template-curly-in-string
'echo "[🏷node:${DETECTED_NODE_VERSION}]"',

'echo \'$ npx @11ty/eleventy --input src --incremental --ignore-initial --output _site\'',
'npx @11ty/eleventy --input src --incremental --ignore-initial --output _site',
'echo \'$ npx @11ty/eleventy --config=$CONFIG_INJECTED --input src --incremental --ignore-initial --output _site\'',
'npx @11ty/eleventy --config=$CONFIG_INJECTED --input src --incremental --ignore-initial --output _site',

'echo "$ source .cloudcannon/postbuild"',
'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi',
Expand Down Expand Up @@ -153,8 +189,8 @@ test('outputs with mange_plugin_manually', () => {
// eslint-disable-next-line no-template-curly-in-string
'echo "[🏷node:${DETECTED_NODE_VERSION}]"',

'echo \'$ npx @11ty/eleventy --output _site\'',
'npx @11ty/eleventy --output _site',
"echo '$ npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site'",
'npx @11ty/eleventy --config=$CONFIG_INJECTED --output _site',

'echo "$ source .cloudcannon/postbuild"',
'if [ -f ".cloudcannon/postbuild" ]; then source .cloudcannon/postbuild; else echo "Not found."; fi',
Expand Down

0 comments on commit e622f58

Please sign in to comment.