How to use @truffle/require - 2 common examples

To help you get started, we’ve selected a few @truffle/require examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trufflesuite / truffle / packages / migrate / migration.js View on Github external
async _load(options, context, deployer, resolver) {
    // Load assets and run `execute`
    const accounts = await context.interfaceAdapter.getAccounts();
    const requireOptions = {
      file: this.file,
      context: context,
      resolver: resolver,
      args: [deployer]
    };

    const fn = Require.file(requireOptions);

    const unRunnable = !fn || !fn.length || fn.length == 0;

    if (unRunnable) {
      const msg = `Migration ${
        this.file
      } invalid or does not take any parameters`;
      throw new Error(msg);
    }

    // `migrateFn` might be sync or async. We negotiate that difference in
    // `execute` through the deployer API.
    const migrateFn = fn(deployer, options.network, accounts);
    await this._deploy(options, deployer, resolver, migrateFn);
  }
github trufflesuite / truffle / packages / truffle-core / lib / commands / exec.js View on Github external
// `--compile`
        if (options.c || options.compile) {
          return Contracts.compile(config, function(err) {
            if (err) return done(err);

            Require.exec(
              config.with({
                file: file
              }),
              done
            );
          });
        }

        // Just exec
        Require.exec(
          config.with({
            file: file
          }),
          done
        );
      })
      .catch(error => {

@truffle/require

Require and execute a Javascript module within a Truffle context

MIT
Latest version published 1 year ago

Package Health Score

50 / 100
Full package analysis

Popular @truffle/require functions