validate method

bool validate ()

check options combinations

Implementation

bool validate() {
  if (input.isNotEmpty) {
    inputBase = input;
    filename = input;
    if (input != '-') {
      //input = path.normalize(path.absolute(input)); //use absolute path
      paths.insert(0, File(input).parent.path);
    }
  } else {
    logger.error('lessc: no input files\n');
    printUsage();
    parseError = true;
    return false;
  }

  if (output.isNotEmpty) {
    outputBase = output;
    //output = path.normalize(path.absolute(output)); //use absolute path
  }

  if (sourceMap) {
    sourceMapOptions.sourceMapInputFilename = input;
    if (sourceMapOptions.sourceMapFullFilename.isEmpty) {
      if (output.isEmpty && !sourceMapOptions.sourceMapFileInline) {
        logger
          ..error(
              'the sourcemap option only has an optional filename if the css filename is given')
          ..error(
              'consider adding --source-map-map-inline which embeds the sourcemap into the css');
        parseError = true;
        return false;
      }

      // its in the same directory, so always just the basename
      sourceMapOptions
        ..sourceMapOutputFilename = path_lib.basename(output)
        ..sourceMapFullFilename = '$output.map'
        ..sourceMapFilename =
            path_lib.basename(sourceMapOptions.sourceMapFullFilename);
    } else if (!sourceMapOptions.sourceMapFileInline) {
      final mapFilename =
          path_lib.absolute(sourceMapOptions.sourceMapFullFilename);
      final mapDir = path_lib.dirname(mapFilename);
      final outputDir = path_lib.dirname(output);

      sourceMapOptions
        // find the path from the map to the output file
        ..sourceMapOutputFilename = path_lib.normalize(path_lib.join(
            path_lib.relative(mapDir, from: outputDir),
            path_lib.basename(output)))
        // make the sourcemap filename point to the sourcemap relative to the css file output directory
        ..sourceMapFilename = path_lib.normalize(path_lib.join(
            path_lib.relative(outputDir, from: mapDir),
            path_lib.basename(sourceMapOptions.sourceMapFullFilename)));
    }
  }

  if (sourceMapOptions.sourceMapBasepath.isEmpty) {
    sourceMapOptions.sourceMapBasepath =
        input.isNotEmpty ? path_lib.dirname(input) : path_lib.current;
  }

  if (sourceMapOptions.sourceMapRootpath.isEmpty) {
    final pathToMap = path_lib.dirname(sourceMapOptions.sourceMapFileInline
        ? output
        : sourceMapOptions.sourceMapFullFilename);
    final pathToInput =
        path_lib.dirname(sourceMapOptions.sourceMapInputFilename);
    sourceMapOptions.sourceMapRootpath =
        path_lib.relative(pathToMap, from: pathToInput);
  }

  if (depends) {
    if (outputBase.isEmpty) {
//        logger.error('option --depends requires an output path to be specified');
//        parseError = true;
//        return false;
      return exitError(
          'option --depends requires an output path to be specified');
    }
  }

  return true;
}