let fs = require('fs');

const dirNames = __dirname.split('/');
const projectName = dirNames[dirNames.length - 2];
const path = '../play/assets'
let folderName = '';
fs.readdirSync(path).find(fileName => {
  const st = fs.statSync(`${path}/${fileName}`);
  if (st.isDirectory()) {
    folderName = fileName;
  }
});

if (projectName != folderName) {
  throw (`项目名(${projectName})与bundle文件夹名(${folderName})不相同`);
}
let same = false;
const files = fs.readdirSync(`${path}/${folderName}/scene`);
files.forEach(fileName => {
  fileName.split('.').forEach((str, idx, arr) => {
    if (str == 'fire') {
      const sceneName = arr[idx - 1];
      if (folderName == sceneName) {
        same = true;
      }
    }
  })
});

if (!same) {
  throw (`bundle文件夹名称(${folderName})与scene名称不相同`);
}

// 'caller', 'callee', and 'arguments'