Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: web/web.py

Issue 2935473002: [web] Fix duplicate dep, strengthen provisioning. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « web/package.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: web/web.py
diff --git a/web/web.py b/web/web.py
index 2f757f47fd772d9710ad472df733aea2262719d3..13e90e1732171b9346979a03fb9ba78d75488752 100755
--- a/web/web.py
+++ b/web/web.py
@@ -13,9 +13,11 @@ This script can be run in one of three modes:
"""
import argparse
+import itertools
import logging
import os
import pipes
+import shutil
import subprocess
import sys
@@ -63,6 +65,7 @@ class Toolchain(object):
install_npm_deps,
os.path.join(web_dir, '.npm.installed'),
os.path.join(web_dir, 'package.json'),
+ [os.path.join(web_dir, 'node_modules')],
force)
# Install Bower deps from "bower.json".
@@ -72,12 +75,13 @@ class Toolchain(object):
install_bower_deps,
os.path.join(web_dir, '.bower.installed'),
os.path.join(web_dir, 'bower.json'),
+ [os.path.join(web_dir, 'inc', 'bower_components')],
force)
return tc
@staticmethod
- def _call_if_outdated(fn, manifest_path, defs_path, force):
+ def _call_if_outdated(fn, manifest_path, defs_path, clean_paths, force):
"""Will call "fn" if the file at "install_path" doesn't match "spec".
If "fn" completes without raising an exception, the "spec" file will be
@@ -88,6 +92,8 @@ class Toolchain(object):
fn (callable): The function to call if they don't match.
manifest_path (str): The path to the installed state file.
defs_path (str): The path to the source spec file.
+ clean_paths (list): Path of destination files and directories to clean on
+ reprovision.
force (bool): If true, call the function regardless.
"""
with open(defs_path, 'r') as fd:
@@ -99,6 +105,15 @@ class Toolchain(object):
if spec_data == current:
return
+ # Clean all paths.
+ for path in itertools.chain(clean_paths, (manifest_path,)):
+ if os.path.isdir(path):
+ LOGGER.info('Purging directory on reprovision: %r', path)
+ shutil.rmtree(path)
+ elif os.path.isfile(path):
+ LOGGER.info('Purging file on reprovision: %r', path)
+ os.remove(path)
+
# Either forcing or out of date.
fn()
« no previous file with comments | « web/package.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698