Skip to content

Commit

Permalink
Update build-from-environment.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
andershagbard committed Oct 7, 2024
1 parent a59f838 commit df3f4c6
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/actions/parts/build-from-environment.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
import * as core from '@actions/core';
import fs from 'fs-extra';
import path from 'path';
import config from '../../helpers/config';
import { BUILD_DIR, THEME_KIT_ENVIRONMENT } from '../../inputs';
import {getIgnoredAssets, themeDirectories} from '../../helpers/shopify';
import path from "path";
import { getIgnoredAssets, themeDirectories } from '../../helpers/shopify';

export default async (): Promise<void> => {
const environment = config[THEME_KIT_ENVIRONMENT];
const themeId = parseInt(environment.theme_id, 10);
const ignoredFiles = environment.ignore_files;
const directory = environment.directory ?? './';

if (themeDirectories.includes(BUILD_DIR)) {
core.error(
'BUILD_DIR cannot be the same as one of the default Shopify theme directories',
);
}

// Copy existing source directory
core.info(`Copying directory "${directory}" to "${BUILD_DIR}"`);

fs.emptyDirSync(BUILD_DIR);

themeDirectories.forEach((folder) => {
fs.copySync(path.join(directory, folder), BUILD_DIR, {
filter: (src) => {
core.info(`Src: ${src}`)

return !src.includes('node_modules')
themeDirectories.forEach((themeDirectory) => {
fs.copySync(
path.join(directory, themeDirectory),
path.join(BUILD_DIR, themeDirectory),
{
filter: (src) => !src.includes('node_modules'),
},
});
);
});

// Copy ignored files from environment
Expand Down

0 comments on commit df3f4c6

Please sign in to comment.