capacitor-resources icon indicating copy to clipboard operation
capacitor-resources copied to clipboard

iocon folder not found when processing only splash image

Open carlosen14 opened this issue 4 years ago • 4 comments

I ran: npx capacitor-resources -S -p android

I got:

📦  Capacitor Resources v2.0.5
-----------------------------

Checking files and directories...
 ✓  Processing files for: android
 ✓  Splash file ok (5008x5008)
 ✓  Output directory ok (resources)

Generating files...
 ✓  Generated splash files for android
 ✓  Successfully generated all files
Root path: /home/carlos/node-proyects/app
npx: installed 7 in 10.015s
(node:28480) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, scandir '/home/carlos/node-proyects/app/resources/android/icon'
    at Object.readdirSync (fs.js:955:3)
    at klawSync (/home/carlos/.nvm/versions/node/v12.20.0/lib/node_modules/capacitor-resources/node_modules/klaw-sync/klaw-sync.js:13:25)
    at /home/carlos/.nvm/versions/node/v12.20.0/lib/node_modules/capacitor-resources/src/copy/platforms/android/index.js:26:21
    at new Promise (<anonymous>)
    at getAndroidIcons (/home/carlos/.nvm/versions/node/v12.20.0/lib/node_modules/capacitor-resources/src/copy/platforms/android/index.js:24:10)
    at copyAndroidIcons (/home/carlos/.nvm/versions/node/v12.20.0/lib/node_modules/capacitor-resources/src/copy/platforms/android/index.js:39:23)
    at /home/carlos/.nvm/versions/node/v12.20.0/lib/node_modules/capacitor-resources/src/copy/platforms/android/index.js:106:13
    at new Promise (<anonymous>)
    at Object.<anonymous> (/home/carlos/.nvm/versions/node/v12.20.0/lib/node_modules/capacitor-resources/src/copy/platforms/android/index.js:103:18)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
(node:28480) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:28480) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

----------------------------------------------

📦  Capacitor resources generated successfully!

Root path: /home/carlos/node-proyects/app
npx: installed 7 in 1.135s

even it generated the splash image, there is an unhandled rejection.

carlosen14 avatar Feb 24 '21 16:02 carlosen14

I had the same problem, and I solved removing a space in the one folder in may root path. Apparently it's the problem, when have any space in directories on root path it broken.

alexcvcoelho avatar Jul 17 '21 23:07 alexcvcoelho

same problem

AlexCs389 avatar Aug 03 '21 18:08 AlexCs389

I've found the cause and created a PR to address it. It seems that this repo might be dead though. https://github.com/leonardoquevedox/capacitor-resources/pull/12

bvdalling avatar Feb 08 '22 18:02 bvdalling

For those who need this solved:

Replace src/copy/index.js with

module.exports = () => {
  return new Promise(async (resolve, reject) => {
    try {
      const copyAndroid = path.join(__dirname, './platforms/android/index')
      const copyIOS = path.join(__dirname, './platforms/ios/index')
      // display.header('Copying resources to native projects...')
      await exec(`npx cross-env CAPACITOR_PROJECT_ROOT="${paths.getRootPath()}" node "${copyAndroid}"`)
      // display.success('Copied android resources')
      await exec(`npx cross-env CAPACITOR_PROJECT_ROOT="${paths.getRootPath()}" node "${copyIOS}"`)
      // display.success('Copied iOS resources')
      resolve()
    } catch (e) {
      reject(e)
    }
  })
}

And then use a package such as Patch Package to save the changes between development and deployment.

bvdalling avatar Feb 08 '22 19:02 bvdalling