setExtension method

String setExtension(
  1. String path,
  2. String extension
)

Returns path with the trailing extension set to extension.

If path doesn't have a trailing extension, this just adds extension to the end.

p.setExtension('path/to/foo.dart', '.js') // -> 'path/to/foo.js'
p.setExtension('path/to/foo.dart.js', '.map')
  // -> 'path/to/foo.dart.map'
p.setExtension('path/to/foo', '.js') // -> 'path/to/foo.js'

Implementation

String setExtension(String path, String extension) => p.context.setExtension(path, extension);