From 455394db56a5a67908d962e31297effce2d44059 Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Wed, 31 Jul 2024 22:35:10 +0100 Subject: [PATCH] feat: expose generateScripts and generateStyles methods --- index.js | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index 22a45d5..a0b2154 100644 --- a/index.js +++ b/index.js @@ -19,28 +19,28 @@ module.exports = function defineShipwrightHook(sails) { const files = data.allFiles return files } - function generateScripts() { - const manifestFiles = getManifestFiles() - let scripts = [] - manifestFiles.forEach((file) => { - if (file.endsWith('.js')) { - scripts.push(``) - } - }) - return scripts.join('\n') - } - function generateStyles() { - const manifestFiles = getManifestFiles() - let styles = [] - manifestFiles.forEach((file) => { - if (file.endsWith('.css')) { - styles.push(``) - } - }) - return styles.join('\n') - } return { + generateScripts: function generateScripts() { + const manifestFiles = getManifestFiles() + let scripts = [] + manifestFiles.forEach((file) => { + if (file.endsWith('.js')) { + scripts.push(``) + } + }) + return scripts.join('\n') + }, + generateStyles: function generateStyles() { + const manifestFiles = getManifestFiles() + let styles = [] + manifestFiles.forEach((file) => { + if (file.endsWith('.css')) { + styles.push(``) + } + }) + return styles.join('\n') + }, defaults: { shipwright: { build: {} @@ -50,6 +50,7 @@ module.exports = function defineShipwrightHook(sails) { * Runs when this Sails app loads/lifts. */ initialize: async function () { + const hook = this const appPath = sails.config.appPath const defaultConfigs = defineConfig({ source: { @@ -139,7 +140,10 @@ module.exports = function defineShipwrightHook(sails) { sails.after('lifted', () => {}) } sails.config.views.locals = { - shipwright: { scripts: generateScripts, styles: generateStyles } + shipwright: { + scripts: hook.generateScripts, + styles: hook.generateStyles + } } } catch (error) { sails.log.error(error)