Skip to content

Commit

Permalink
Make npm install a dependency of node based targets
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaub committed Oct 24, 2014
1 parent 8eaeb7b commit 5cab561
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def wait_completion(self):
if path.endswith('.js')
if path not in SHADER_SRC]

NPM_INSTALL = 'build/npm-install-timestamp'

def report_sizes(t):
stringio = StringIO()
Expand Down Expand Up @@ -176,18 +177,25 @@ def report_sizes(t):
virtual('todo', 'fixme')


@target('build/ol.css', 'css/ol.css')
@target(NPM_INSTALL, 'package.json')
def npm_install(t):
t.run('npm', 'install')
t.touch()


@target('build/ol.css', 'css/ol.css', NPM_INSTALL)
def build_ol_css(t):
t.output('%(CLEANCSS)s', 'css/ol.css')


@target('build/ol.js', SRC, SHADER_SRC, 'config/ol.json')
@target('build/ol.js', SRC, SHADER_SRC, 'config/ol.json', NPM_INSTALL)
def build_ol_new_js(t):
t.run('node', 'tasks/build.js', 'config/ol.json', 'build/ol.js')
report_sizes(t)


@target('build/ol-debug.js', SRC, SHADER_SRC, 'config/ol-debug.json')
@target('build/ol-debug.js', SRC, SHADER_SRC, 'config/ol-debug.json',
NPM_INSTALL)
def build_ol_debug_js(t):
t.run('node', 'tasks/build.js', 'config/ol-debug.json', 'build/ol-debug.js')
report_sizes(t)
Expand Down Expand Up @@ -236,7 +244,7 @@ def examples_examples_list_js(t):


@target('build/examples/all.combined.js', 'build/examples/all.js',
SRC, SHADER_SRC, 'config/examples-all.json')
SRC, SHADER_SRC, 'config/examples-all.json', NPM_INSTALL)
def build_examples_all_combined_js(t):
t.run('node', 'tasks/build.js', 'config/examples-all.json',
'build/examples/all.combined.js')
Expand Down Expand Up @@ -344,7 +352,8 @@ def action(t):
})
with open(t.name, 'wb') as f:
f.write(content)
return Target(name, action=action, dependencies=[__file__])
return Target(name, action=action,
dependencies=[__file__, NPM_INSTALL])


@rule(r'\Abuild/examples/(?P<id>.*).combined.js\Z')
Expand All @@ -355,11 +364,12 @@ def action(t):
report_sizes(t)
dependencies = [SRC, SHADER_SRC,
'examples/%(id)s.js' % match.groupdict(),
'build/examples/%(id)s.json' % match.groupdict()]
'build/examples/%(id)s.json' % match.groupdict(),
NPM_INSTALL]
return Target(name, action=action, dependencies=dependencies)


@target('serve', 'examples')
@target('serve', 'examples', NPM_INSTALL)
def serve(t):
t.run('node', 'tasks/serve.js')

Expand All @@ -377,11 +387,10 @@ def build_lint_src_timestamp(t):
t.newer(t.dependencies))
t.touch()


virtual('jshint', 'build/jshint-timestamp')

@target('build/jshint-timestamp', SRC, EXAMPLES_SRC, SPEC, TASKS,
precious=True)
NPM_INSTALL, precious=True)
def build_jshint_timestamp(t):
t.run(variables.JSHINT, '--verbose', t.newer(t.dependencies))
t.touch()
Expand Down Expand Up @@ -587,7 +596,8 @@ def build_check_whitespace_timestamp(t):


@target('build/jsdoc-%(BRANCH)s-timestamp' % vars(variables), 'host-resources',
SRC, SHADER_SRC, ifind('config/jsdoc/api/template'))
SRC, SHADER_SRC, ifind('config/jsdoc/api/template'),
NPM_INSTALL)
def jsdoc_BRANCH_timestamp(t):
t.run('%(JSDOC)s', 'config/jsdoc/api/index.md',
'-c', 'config/jsdoc/api/conf.json',
Expand Down Expand Up @@ -684,7 +694,7 @@ def check_examples(t):
sys.exit(1)


@target('test', phony=True)
@target('test', NPM_INSTALL, phony=True)
def test(t):
t.run('node', 'tasks/test.js')

Expand Down

0 comments on commit 5cab561

Please sign in to comment.