How to use the aurelia-cli.CLIOptions.hasFlag function in aurelia-cli

To help you get started, we’ve selected a few aurelia-cli 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 airform / airform / packages / aurelia-airform / aurelia_project / tasks / build-plugin.ts View on Github external
pluginJson('dist/native-modules'),
    buildPluginJavaScript('dist/native-modules', 'es2015'),

    // package.json "main" field pointing to dist/native-modules/index.js
    pluginMarkup('dist/commonjs'),
    pluginCSS('dist/commonjs'),
    pluginJson('dist/commonjs'),
    buildPluginJavaScript('dist/commonjs', 'commonjs'),
  ), (done) => {
    console.log('Finish building Aurelia plugin to dist/commonjs and dist/native-modules.');
    done();
  }
);

let main;
if (CLIOptions.hasFlag('watch')) {
  main = gulp.series(
    clean,
    () => {
      console.log('Watching plugin sources for changes ...');
      return gulp.watch('src/**/*', { ignoreInitial: false }, build);
    }
  );
} else {
  main = gulp.series(
    clean,
    build
  );
}

export { main as default };
github aurelia / cli / lib / resources / tasks / run-webpack.ts View on Github external
function runWebpack(done) {
  // https://webpack.github.io/docs/webpack-dev-server.html
  let opts = {
    host: 'localhost',
    publicPath: config.output.publicPath,
    filename: config.output.filename,
    hot: project.platform.hmr || CLIOptions.hasFlag('hmr'),
    port: project.platform.port,
    contentBase: config.output.path,
    historyApiFallback: true,
    open: project.platform.open,
    stats: {
      colors: require('supports-color')
    },
    https: config.devServer.https
  } as any;

  // Add the webpack-dev-server client to the webpack entry point
  // The path for the client to use such as `webpack-dev-server/client?http://${opts.host}:${opts.port}/` is not required
  // The path used is derived from window.location in the browser and output.publicPath in the webpack.config.
  if (project.platform.hmr || CLIOptions.hasFlag('hmr')) {
    config.plugins.push(new webpack.HotModuleReplacementPlugin());
    config.entry.app.unshift('webpack-dev-server/client', 'webpack/hot/dev-server');
github Vheissu / aureliapress / app / aurelia_project / tasks / run.ts View on Github external
function runWebpack(done) {
  // https://webpack.github.io/docs/webpack-dev-server.html
  let opts = {
    host: 'localhost',
    publicPath: config.output.publicPath,
    filename: config.output.filename,
    hot: project.platform.hmr || CLIOptions.hasFlag('hmr'),
    port: project.platform.port,
    contentBase: config.output.path,
    historyApiFallback: true,
    open: project.platform.open,
    stats: {
      colors: require('supports-color')
    },
    https: config.devServer.https
  } as any;

  if (project.platform.hmr || CLIOptions.hasFlag('hmr')) {
    config.plugins.push(new webpack.HotModuleReplacementPlugin());
    config.entry.app.unshift(`webpack-dev-server/client?http://${opts.host}:${opts.port}/`, 'webpack/hot/dev-server');
  }

  const compiler = webpack(config);
github zeit / now / test / dev / fixtures / 03-aurelia / aurelia_project / tasks / build.js View on Github external
function onBuild(err, stats) {
  if (!CLIOptions.hasFlag('watch') && err) {
    console.error(err.stack || err);
    if (err.details) console.error(err.details);
    process.exit(1);
  } else {
    process.stdout.write(stats.toString({ colors: require('supports-color') }) + '\n');

    if (!CLIOptions.hasFlag('watch') && stats.hasErrors()) {
      process.exit(1);
    }
  }
}
github aurelia / cli / lib / resources / tasks / run.ts View on Github external
});
  }
);

function log(message) {
  console.log(message);
}

function reload() {
  log('Refreshing the browser');
  browserSync.reload();
}

let run;

if (CLIOptions.hasFlag('watch')) {
  run = gulp.series(
    serve,
    done => { watch(reload); done(); }
  );
} else {
  run = serve;
}

export default run;
github aurelia / cli / lib / resources / tasks / build-webpack.js View on Github external
import webpackConfig from '../../webpack.config';
import webpack from 'webpack';
import project from '../aurelia.json';
import {CLIOptions, Configuration} from 'aurelia-cli';
import gulp from 'gulp';
import configureEnvironment from './environment';
import del from 'del';

const analyze = CLIOptions.hasFlag('analyze');
const buildOptions = new Configuration(project.build.options);
const production = CLIOptions.getEnvironment() === 'prod';
const server = buildOptions.isApplicable('server');
const extractCss = buildOptions.isApplicable('extractCss');
const coverage = buildOptions.isApplicable('coverage');

const config = webpackConfig({
  production, server, extractCss, coverage, analyze
});
const compiler = webpack(config);

function buildWebpack(done) {
  if (CLIOptions.hasFlag('watch')) {
    compiler.watch({}, onBuild);
  } else {
    compiler.run(onBuild);
github aurelia / cli / lib / resources / tasks / cypress.js View on Github external
export default () => {
  if (CLIOptions.hasFlag('run')) {
    cypress.run(config);
  } else {
    cypress.open(config);
  }
};