'use strict';

const { join } = require('path');
const { copyFileSync, existsSync } = require('fs');

exports.copyThemeVariables = (srcDir, theme) => {
  const themeDir = join(srcDir, '_themes');
  const variableFile = join(srcDir, 'variables.scss');
  const sourceThemeVariableFile = join(themeDir, `variables.${theme}.scss`);
  if (!existsSync(sourceThemeVariableFile)) {
    throw new Error(`cannot find ${sourceThemeVariableFile}`);
  }
  copyFileSync(sourceThemeVariableFile, variableFile);
};
