Return a Command that checks that certain files exist. Raises a ValueError if any of the files are missing. Note: The check is skipped if the `--skip-npm` flag is used.
(targets)
| 380 | |
| 381 | |
| 382 | def ensure_targets(targets): |
| 383 | """Return a Command that checks that certain files exist. |
| 384 | |
| 385 | Raises a ValueError if any of the files are missing. |
| 386 | |
| 387 | Note: The check is skipped if the `--skip-npm` flag is used. |
| 388 | """ |
| 389 | |
| 390 | class TargetsCheck(BaseCommand): |
| 391 | def run(self): |
| 392 | if skip_npm: |
| 393 | log.info('Skipping target checks') |
| 394 | return |
| 395 | missing = [t for t in targets if not os.path.exists(t)] |
| 396 | if missing: |
| 397 | raise ValueError(('missing files: %s' % missing)) |
| 398 | |
| 399 | return TargetsCheck |
| 400 | |
| 401 | |
| 402 | # `shutils.which` function copied verbatim from the Python-3.3 source. |