Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed Aug 10, 2022
1 parent 93d5f7e commit 1d23e43
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions scripts/plugins/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ export function getEnabledPlugins() {
}

export function movePluginFilesToWebview(folderName, extensions, isSrc = false) {
const normalizedName = `${folderName}`.replace('webview/', '')
const normalizedName = `${folderName}`.replace('webview/', '');

// First Perform Extension & Sub Directory Cleanup
let oldFiles;

if (!isSrc) {
oldFiles = glob.sync(sanitizePath(path.join(`src-webviews/public/plugins/${normalizedName}/**/*.+(${extensions.join('|')})`)));
oldFiles = glob.sync(
sanitizePath(path.join(`src-webviews/public/plugins/${normalizedName}/**/*.+(${extensions.join('|')})`)),
);
} else {
oldFiles = glob.sync(sanitizePath(path.join(`src-webviews/src/plugins/${normalizedName}/**/*.+(${extensions.join('|')})`)));
oldFiles = glob.sync(
sanitizePath(path.join(`src-webviews/src/plugins/${normalizedName}/**/*.+(${extensions.join('|')})`)),
);
}

for (let oldFile of oldFiles) {
Expand All @@ -60,16 +64,22 @@ export function movePluginFilesToWebview(folderName, extensions, isSrc = false)
continue;
}

const allFiles = glob.sync(sanitizePath(path.join(pluginFolder, `${folderName}/**/*.+(${extensions.join('|')})`)));
const allFiles = glob.sync(
sanitizePath(path.join(pluginFolder, `${folderName}/**/*.+(${extensions.join('|')})`)),
);
for (let i = 0; i < allFiles.length; i++) {
const filePath = allFiles[i];
const regExp = new RegExp(`.*\/${folderName}\/`);
let finalPath;

if (!isSrc) {
finalPath = sanitizePath(filePath.replace(regExp, `src-webviews/public/plugins/${normalizedName}/${pluginName}/`))
finalPath = sanitizePath(
filePath.replace(regExp, `src-webviews/public/plugins/${normalizedName}/${pluginName}/`),
);
} else {
finalPath = sanitizePath(filePath.replace(regExp, `src-webviews/src/plugins/${normalizedName}/${pluginName}/`))
finalPath = sanitizePath(
filePath.replace(regExp, `src-webviews/src/plugins/${normalizedName}/${pluginName}/`),
);
}

if (fs.existsSync(filePath)) {
Expand All @@ -85,13 +95,18 @@ export function movePluginFilesToWebview(folderName, extensions, isSrc = false)
}

if (amountCopied >= 1 && extensions.includes('css')) {
console.warn('! ============ !')
console.warn(`You're using the 'css' folder. In order to reflect changes you must restart the vue server for it to update.`)
console.warn(`You should move the style to the style tag in your component.`)
console.warn(`Externally styling with Athena is poorly supported and may never work correctly.`)
console.warn(`This is fine if you have preset styles already built and don't plan on making changes in the future.`)
console.warn('! ============ !')
console.warn('! ============ !');
console.warn(
`You're using the 'css' folder. In order to reflect changes you must restart the vue server for it to update.`,
);
console.warn(`You should move the style to the style tag in your component.`);
console.warn(`Externally styling with Athena is poorly supported and may never work correctly.`);
console.warn(
`This is fine if you have preset styles already built and don't plan on making changes in the future.`,
);
console.warn(`CSS Import Pathing Should Be: '@/plugins/css/your-plugin/some-style.css`);
console.warn('! ============ !');
}

console.log(`${folderName} - ${amountCopied} Files Added to WebView Plugins - (${extensions.join('|')})`)
}
console.log(`${folderName} - ${amountCopied} Files Added to WebView Plugins - (${extensions.join('|')})`);
}

0 comments on commit 1d23e43

Please sign in to comment.