# Copyright 2021 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("./vars.gni")

template("node_action") {
  assert(defined(invoker.script),
         "You must define the 'script' for a Node action")

  action(target_name) {
    script = "//third_party/node/node.py"

    forward_variables_from(invoker,
                           "*",
                           [
                             "args",
                             "script",
                           ])

    _full_script_location = devtools_location_prepend + invoker.script

    inputs += [
      _full_script_location,
      devtools_location_prepend + "scripts/build/ninja/write-if-changed.js",
    ]

    args = [ rebase_path(_full_script_location, root_build_dir) ] + invoker.args
  }
}

set_defaults("node_action") {
  inputs = []

  args = []
}
