예제 #1
0
    def compile_file(self, source_path):
        args = [
            self.executable,
        ] + self.get_extra_args()

        if self.is_sourcemap_enabled:
            args.append("-s")

        full_output_path = self.get_full_output_path(source_path)

        full_output_dirname = os.path.dirname(full_output_path)
        if not os.path.exists(full_output_dirname):
            os.makedirs(full_output_dirname)

        args.extend(["-o", full_output_path])
        args.append(self.get_full_source_path(source_path))

        return_code, out, errors = utils.run_command(args)
        if return_code:
            raise exceptions.StaticCompilationError(errors)

        if self.is_sourcemap_enabled:
            utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)

        return self.get_output_path(source_path)
예제 #2
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        full_output_path = self.get_full_output_path(source_path)

        # `cwd` is a directory containing `source_path`.
        # Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))

        args = [self.executable]
        if self.is_sourcemap_enabled:
            args.extend(["--source-map"])
        if self.global_vars:
            for variable_name, variable_value in self.global_vars.items():
                args.extend(["--global-var={}={}".format(variable_name, variable_value)])

        args.extend([self.get_full_source_path(source_path), full_output_path])
        out, errors = utils.run_command(args, cwd=cwd)

        if errors:
            raise exceptions.StaticCompilationError(errors)

        utils.convert_urls(full_output_path, source_path)

        if self.is_sourcemap_enabled:
            utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)

        return self.get_output_path(source_path)
    def compile_file(self, source_path):
        full_output_path = self.get_full_output_path(source_path)
        # LiveScript bug with source map if the folder isn't already present
        if not os.path.exists(os.path.dirname(full_output_path)):
            os.makedirs(os.path.dirname(full_output_path))
        args = [
            self.executable,
            "-c",
        ]
        if self.is_sourcemap_enabled:
            args.append("-m")
            args.append("linked")
        args.extend([
            "-o", os.path.dirname(full_output_path),
            self.get_full_source_path(source_path),
        ])
        return_code, out, errors = utils.run_command(args)

        if return_code:
            raise exceptions.StaticCompilationError(errors)

        if self.is_sourcemap_enabled:
            utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)

        return self.get_output_path(source_path)
예제 #4
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        full_output_path = self.get_full_output_path(source_path)
        args = [
            self.executable,
        ]
        if self.is_sourcemap_enabled:
            args.append("-m")
        args.extend([
            full_source_path,
            "-o", os.path.dirname(full_output_path),
        ])

        full_output_dirname = os.path.dirname(full_output_path)
        if not os.path.exists(full_output_dirname):
            os.makedirs(full_output_dirname)

        # `cwd` is a directory containing `source_path`.
        # Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))
        out, errors = utils.run_command(args, cwd=cwd)

        if errors:
            raise exceptions.StaticCompilationError(errors)

        utils.convert_urls(full_output_path, source_path)

        if self.is_sourcemap_enabled:
            utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)

        return self.get_output_path(source_path)
    def compile_file(self, source_path):
        full_output_path = self.get_full_output_path(source_path)
        output_dir = os.path.dirname(full_output_path)

        if not os.path.exists(output_dir):
            os.makedirs(output_dir)

        template_extension = os.path.splitext(source_path)[1].lstrip(".")

        args = [
            self.executable,
            self.get_full_source_path(source_path),
            "-e", template_extension,
            "-f", full_output_path,
        ] + self.get_extra_args()

        if self.is_sourcemap_enabled:
            args += ["--map", full_output_path + ".map"]

        return_code, out, errors = utils.run_command(args)

        if return_code:
            raise exceptions.StaticCompilationError(errors)

        if self.is_sourcemap_enabled:
            utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)

        return self.get_output_path(source_path)
예제 #6
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        full_output_path = self.get_full_output_path(source_path)
        args = [
            self.executable,
            "--sourcemap={}".format("auto" if self.is_sourcemap_enabled else "none"),
        ] + self.get_extra_args()

        args.extend([
            self.get_full_source_path(source_path),
            full_output_path,
        ])

        full_output_dirname = os.path.dirname(full_output_path)
        if not os.path.exists(full_output_dirname):
            os.makedirs(full_output_dirname)

        # `cwd` is a directory containing `source_path`.
        # Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))
        out, errors = utils.run_command(args, None, cwd=cwd)

        if errors:
            if os.path.exists(full_output_path):
                os.remove(full_output_path)
            raise exceptions.StaticCompilationError(errors)

        utils.convert_urls(full_output_path, source_path)

        if self.is_sourcemap_enabled:
            utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)

        return self.get_output_path(source_path)
예제 #7
0
    def compile_file(self, source_path):
        command = "{0} {1}".format(LESS_EXECUTABLE, self.get_full_source_path(source_path))

        out, errors = run_command(command, None, STATIC_ROOT)
        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #8
0
    def compile_source(self, source):
        args = [self.executable] + self.get_extra_args()

        out, errors = utils.run_command(args, source)
        if errors:
            raise exceptions.StaticCompilationError(errors)

        return out
예제 #9
0
    def compile_source(self, source):
        args = [LESS_EXECUTABLE, "-"]

        out, errors = run_command(args, source)

        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #10
0
    def compile_source(self, source):
        command = "{0} -".format(LESS_EXECUTABLE)

        out, errors = run_command(command, source)

        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #11
0
    def compile_source(self, source):
        args = [
            self.executable
        ]
        out, errors = run_command(args, source)
        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #12
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        args = [LESS_EXECUTABLE, full_source_path]
        # `cwd` is a directory containing `source_path`. Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))
        out, errors = run_command(args, None, cwd=cwd)
        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #13
0
    def compile_source(self, source):
        args = [
            self.executable,
            "-p",
        ]
        out, errors = utils.run_command(args, input=source)

        if errors:
            raise exceptions.StaticCompilationError(errors)

        return out
예제 #14
0
    def compile_file(self, source_path):
        command = "{0} -C {1}".format(SCSS_EXECUTABLE, self.get_full_source_path(source_path))

        if SCSS_USE_COMPASS:
            command += " --compass"

        out, errors = run_command(command, None, STATIC_ROOT)
        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #15
0
    def compile_source(self, source):
        command = "{0} -s --scss -C".format(SCSS_EXECUTABLE)

        if SCSS_USE_COMPASS:
            command += " --compass"

        out, errors = run_command(command, source, STATIC_ROOT)
        if errors:
            raise StaticCompilationError(errors)

        return out
    def compile_source(self, source):
        args = [
            self.executable,
            "-c",
            "-s",
            "-p",
        ]
        return_code, out, errors = utils.run_command(args, source)
        if return_code:
            raise exceptions.StaticCompilationError(errors)

        return out
    def compile_source(self, source):
        args = [
            COFFEESCRIPT_EXECUTABLE,
            "-c",
            "-s",
            "-p",
        ]
        out, errors = run_command(args, source)
        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #18
0
    def compile_source(self, source):
        args = [
            self.executable,
            "-s",
        ]
        if self.executable.endswith("scss"):
            args.append("--sass")

        out, errors = utils.run_command(args, source)
        if errors:
            raise exceptions.StaticCompilationError(errors)

        return out
예제 #19
0
    def compile_source(self, source):
        args = [
            self.executable
        ]

        if self.modules is not None:
            args.extend(["--modules", self.modules])

        out, errors = utils.run_command(args, source)
        if errors:
            raise exceptions.StaticCompilationError(errors)

        return out
예제 #20
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        args = [
            self.executable,
            full_source_path,
        ]
        # `cwd` is a directory containing `source_path`.
        # Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))
        out, errors = utils.run_command(args, None, cwd=cwd)
        if errors:
            raise exceptions.StaticCompilationError(errors)

        return out
예제 #21
0
    def compile_source(self, source):
        args = [
            self.executable,
            "-s",
        ] + self.get_extra_args()

        if self.executable.endswith("sass"):
            args.append("--scss")

        return_code, out, errors = utils.run_command(args, source)
        if return_code:
            raise exceptions.StaticCompilationError(errors)

        return out
예제 #22
0
    def compile_source(self, source):
        args = [
            self.executable,
            "-s",
        ] + self.get_extra_args()

        if self.executable.endswith("sass"):
            args.append("--scss")

        out, errors = utils.run_command(args, source)
        if errors:
            raise exceptions.StaticCompilationError(errors)

        return out
예제 #23
0
    def compile_source(self, source):
        args = [
            settings.SCSS_EXECUTABLE,
            "-s",
            "-C",
        ]

        if self.compass_enabled():
            args.append("--compass")

        out, errors = run_command(args, source)
        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #24
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        args = [
            LESS_EXECUTABLE,
            full_source_path,
        ]
        # `cwd` is a directory containing `source_path`. Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(
            os.path.join(full_source_path,
                         *([".."] * len(source_path.split("/")))))
        out, errors = run_command(args, None, cwd=cwd)
        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #25
0
    def compile_source(self, source):
        args = [
            settings.SCSS_EXECUTABLE,
            "-s",
            "-C",
        ]

        if self.compass_enabled():
            args.append("--compass")

        out, errors = run_command(args, source)
        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #26
0
    def compile_source(self, source):
        args = [
            self.executable,
            "-"
        ]

        out, errors = run_command(args, source)

        if errors:
            raise StaticCompilationError(errors)

        if LESS_POST_COMPILE:
            out = LESS_POST_COMPILE(out)

        return out
예제 #27
0
    def compile_source(self, source):
        args = [
            SCSS_EXECUTABLE,
            "-s",
            "-C",
        ]

        if SCSS_USE_COMPASS:
            args.append("--compass")

        out, errors = run_command(args, source)
        if errors:
            raise StaticCompilationError(errors)

        return out
    def compile_source(self, source):
        args = [
            self.executable,
            "-c",
            "-s",
            "-p",
        ]
        if self.transpile:
            args.append("-t")
        if not self.header:
            args.append("--no-header")
        return_code, out, errors = utils.run_command(args, source)
        if return_code:
            raise exceptions.StaticCompilationError(errors)

        return out
예제 #29
0
파일: scss.py 프로젝트: tgiachi/wi2m
    def compile_source(self, source):
        args = [
            self.executable,
            "-s",
        ]
        if self.executable.endswith("sass"):
            args.append("--scss")

        if self.is_compass_enabled:
            args.append("--compass")

        out, errors = run_command(args, source)
        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #30
0
    def compile_source(self, source):
        args = [
            self.executable,
            "-s",
        ]
        if self.executable.endswith("sass"):
            args.append("--scss")

        if self.is_compass_enabled:
            args.append("--compass")

        out, errors = run_command(args, source)
        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #31
0
    def compile_source(self, source):
        args = [
            self.executable,
            "-"
        ]
        if self.include_path:
            args.extend([
                "--include-path={}".format(self.include_path)
            ])

        return_code, out, errors = utils.run_command(args, source)

        if return_code:
            raise exceptions.StaticCompilationError(errors)

        return out
예제 #32
0
파일: scss.py 프로젝트: tgiachi/wi2m
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        args = [
            self.executable,
            full_source_path,
        ]

        if self.is_compass_enabled:
            args.append("--compass")

        # `cwd` is a directory containing `source_path`. Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))
        out, errors = run_command(args, None, cwd=cwd)

        if errors:
            raise StaticCompilationError(errors)

        return out
예제 #33
0
    def compile_file(self, source_path):
        args = [
            self.executable,
        ]

        if self.is_sourcemap_enabled:
            args.append("-s")

        if self.modules is not None:
            args.extend(["--modules", self.modules])

        full_output_path = self.get_full_output_path(source_path)

        full_output_dirname = os.path.dirname(full_output_path)
        if not os.path.exists(full_output_dirname):
            os.makedirs(full_output_dirname)

        args.extend(["-o", full_output_path])
        args.append(self.get_full_source_path(source_path))

        out, errors = utils.run_command(args)
        if errors:
            raise exceptions.StaticCompilationError(errors)

        if self.is_sourcemap_enabled:
            sourcemap_full_path = full_output_path + ".map"

            with open(sourcemap_full_path) as sourcemap_file:
                sourcemap = json.loads(sourcemap_file.read())

            # Babel can't add correct relative paths in source map when the compiled file
            # is not in the same dir as the source file. We fix it here.
            sourcemap["sourceRoot"] = "../" * len(
                source_path.split("/")) + posixpath.dirname(source_path)
            sourcemap["sources"] = [
                os.path.basename(source) for source in sourcemap["sources"]
            ]
            sourcemap["file"] = posixpath.basename(
                os.path.basename(full_output_path))

            with open(sourcemap_full_path, "w") as sourcemap_file:
                sourcemap_file.write(json.dumps(sourcemap))

        return self.get_output_path(source_path)
예제 #34
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        full_output_path = self.get_full_output_path(source_path)

        # `cwd` is a directory containing `source_path`.
        # Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(
            os.path.join(full_source_path,
                         *([".."] * len(source_path.split("/")))))

        args = [self.executable]
        if self.is_sourcemap_enabled:
            args.extend(["--source-map"])
        if self.include_path:
            args.extend(["--include-path={}".format(self.include_path)])
        if self.clean_css:
            args.extend([
                "--clean-css",
            ])
        if self.global_vars:
            for variable_name, variable_value in self.global_vars.items():
                args.extend([
                    "--global-var={0}={1}".format(variable_name,
                                                  variable_value),
                ])

        args.extend([
            self.get_full_source_path(source_path),
        ])
        return_code, out, errors = utils.run_command(args, cwd=cwd)

        with open(full_output_path, "w") as inp:
            inp.write(out)

        if return_code:
            raise exceptions.StaticCompilationError(errors)

        url_converter.convert_urls(full_output_path, source_path)

        if self.is_sourcemap_enabled:
            utils.fix_sourcemap(full_output_path + ".map", source_path,
                                full_output_path)

        return self.get_output_path(source_path)
예제 #35
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        full_output_path = self.get_full_output_path(source_path)

        # `cwd` is a directory containing `source_path`.
        # Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))

        args = [
            self.executable
        ]
        if self.is_sourcemap_enabled:
            args.extend([
                "--source-map"
            ])

        args.extend([
            self.get_full_source_path(source_path),
            full_output_path,
        ])
        out, errors = utils.run_command(args, cwd=cwd)
        if errors:
            raise exceptions.StaticCompilationError(errors)

        utils.convert_urls(full_output_path, source_path)

        if self.is_sourcemap_enabled:
            sourcemap_full_path = full_output_path + ".map"

            with open(sourcemap_full_path) as sourcemap_file:
                sourcemap = json.loads(sourcemap_file.read())

            # LESS, unlike SASS, can't add correct relative paths in source map when the compiled file
            # is not in the same dir as the source file. We fix it here.
            sourcemap["sourceRoot"] = "../" * len(source_path.split("/")) + posixpath.dirname(source_path)

            sourcemap["file"] = posixpath.basename(full_output_path)

            with open(sourcemap_full_path, "w") as sourcemap_file:
                sourcemap_file.write(json.dumps(sourcemap))

        return self.get_output_path(source_path)
예제 #36
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        full_output_path = self.get_full_output_path(source_path)

        # `cwd` is a directory containing `source_path`.
        # Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(
            os.path.join(full_source_path,
                         *([".."] * len(source_path.split("/")))))

        args = [self.executable]
        if self.is_sourcemap_enabled:
            args.extend(["--source-map"])

        args.extend([
            self.get_full_source_path(source_path),
            full_output_path,
        ])
        out, errors = utils.run_command(args, cwd=cwd)
        if errors:
            raise exceptions.StaticCompilationError(errors)

        utils.convert_urls(full_output_path, source_path)

        if self.is_sourcemap_enabled:
            sourcemap_full_path = full_output_path + ".map"

            with open(sourcemap_full_path) as sourcemap_file:
                sourcemap = json.loads(sourcemap_file.read())

            # LESS, unlike SASS, can't add correct relative paths in source map when the compiled file
            # is not in the same dir as the source file. We fix it here.
            sourcemap["sourceRoot"] = "../" * len(
                source_path.split("/")) + posixpath.dirname(source_path)

            sourcemap["file"] = posixpath.basename(full_output_path)

            with open(sourcemap_full_path, "w") as sourcemap_file:
                sourcemap_file.write(json.dumps(sourcemap))

        return self.get_output_path(source_path)
예제 #37
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        args = [
            self.executable,
            full_source_path,
        ]

        if self.is_compass_enabled:
            args.append("--compass")

        # `cwd` is a directory containing `source_path`.
        # Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(
            os.path.join(full_source_path,
                         *([".."] * len(source_path.split("/")))))
        out, errors = run_command(args, None, cwd=cwd)

        if errors:
            raise StaticCompilationError(errors)

        return out
    def compile_file(self, source_path):
        full_output_path = self.get_full_output_path(source_path)
        args = [
            self.executable,
            "-c",
        ]
        if self.is_sourcemap_enabled:
            args.append("-m")
        args.extend([
            "-o", os.path.dirname(full_output_path),
            self.get_full_source_path(source_path),
        ])
        return_code, out, errors = utils.run_command(args)

        if return_code:
            raise exceptions.StaticCompilationError(errors)

        if self.is_sourcemap_enabled:
            utils.fix_sourcemap(os.path.splitext(full_output_path)[0] + ".map", source_path, full_output_path)

        return self.get_output_path(source_path)
예제 #39
0
    def compile_file(self, source_path):
        full_output_path = self.get_full_output_path(source_path)
        args = [
            self.executable,
            "-c",
        ]
        if self.is_sourcemap_enabled:
            args.append("-m")
        args.extend([
            "-o",
            os.path.dirname(full_output_path),
            self.get_full_source_path(source_path),
        ])
        out, errors = utils.run_command(args)

        if errors:
            raise exceptions.StaticCompilationError(errors)

        if self.is_sourcemap_enabled:
            # Coffeescript writes source maps to compiled.map, not compiled.js.map
            sourcemap_full_path = os.path.splitext(
                full_output_path)[0] + ".map"

            with open(sourcemap_full_path) as sourcemap_file:
                sourcemap = json.loads(sourcemap_file.read())

            # CoffeeScript, unlike SASS, can't add correct relative paths in source map when the compiled file
            # is not in the same dir as the source file. We fix it here.
            sourcemap["sourceRoot"] = "../" * len(
                source_path.split("/")) + posixpath.dirname(source_path)
            sourcemap["sources"] = [
                os.path.basename(source) for source in sourcemap["sources"]
            ]
            sourcemap["file"] = posixpath.basename(
                os.path.basename(full_output_path))

            with open(sourcemap_full_path, "w") as sourcemap_file:
                sourcemap_file.write(json.dumps(sourcemap))

        return self.get_output_path(source_path)
예제 #40
0
    def compile_file(self, source_path):
        args = [
            self.executable,
        ]

        if self.is_sourcemap_enabled:
            args.append("-s")

        if self.modules is not None:
            args.extend(["--modules", self.modules])

        full_output_path = self.get_full_output_path(source_path)

        full_output_dirname = os.path.dirname(full_output_path)
        if not os.path.exists(full_output_dirname):
            os.makedirs(full_output_dirname)

        args.extend(["-o", full_output_path])
        args.append(self.get_full_source_path(source_path))

        out, errors = utils.run_command(args)
        if errors:
            raise exceptions.StaticCompilationError(errors)

        if self.is_sourcemap_enabled:
            sourcemap_full_path = full_output_path + ".map"

            with open(sourcemap_full_path) as sourcemap_file:
                sourcemap = json.loads(sourcemap_file.read())

            # Babel can't add correct relative paths in source map when the compiled file
            # is not in the same dir as the source file. We fix it here.
            sourcemap["sourceRoot"] = "../" * len(source_path.split("/")) + posixpath.dirname(source_path)
            sourcemap["sources"] = [os.path.basename(source) for source in sourcemap["sources"]]
            sourcemap["file"] = posixpath.basename(os.path.basename(full_output_path))

            with open(sourcemap_full_path, "w") as sourcemap_file:
                sourcemap_file.write(json.dumps(sourcemap))

        return self.get_output_path(source_path)
예제 #41
0
    def compile_file(self, source_path):
        full_source_path = self.get_full_source_path(source_path)
        full_output_path = self.get_full_output_path(source_path)
        args = [
            self.executable,
            "--sourcemap={}".format(
                "auto" if self.is_sourcemap_enabled else "none"),
        ] + self.get_extra_args()

        args.extend([
            self.get_full_source_path(source_path),
            full_output_path,
        ])

        full_output_dirname = os.path.dirname(full_output_path)
        if not os.path.exists(full_output_dirname):
            os.makedirs(full_output_dirname)

        # `cwd` is a directory containing `source_path`.
        # Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
        cwd = os.path.normpath(
            os.path.join(full_source_path,
                         *([".."] * len(source_path.split("/")))))
        out, errors = utils.run_command(args, None, cwd=cwd)

        if errors:
            if os.path.exists(full_output_path):
                os.remove(full_output_path)
            raise exceptions.StaticCompilationError(errors)

        utils.convert_urls(full_output_path, source_path)

        if self.is_sourcemap_enabled:
            utils.fix_sourcemap(full_output_path + ".map", source_path,
                                full_output_path)

        return self.get_output_path(source_path)
예제 #42
0
    def compile_file(self, source_path):
        full_output_path = self.get_full_output_path(source_path)
        args = [
            self.executable,
            "-c",
        ]
        if self.is_sourcemap_enabled:
            args.append("-m")
        args.extend([
            "-o",
            os.path.dirname(full_output_path),
            self.get_full_source_path(source_path),
        ])
        out, errors = utils.run_command(args)

        if errors:
            raise exceptions.StaticCompilationError(errors)

        if self.is_sourcemap_enabled:
            utils.fix_sourcemap(
                os.path.splitext(full_output_path)[0] + ".map", source_path,
                full_output_path)

        return self.get_output_path(source_path)