Ejemplo n.º 1
0
    def dart_pub_get(self, path_to_pubspec):
        path_to_pubspec = path_to_pubspec or self.window.active_view(
        ).file_name()
        if not path_to_pubspec:
            _logger.error('no pubspec specified for "pub get"')
            return

        package = PubPackage.from_path(path_to_pubspec)
        if not package:
            _logger.info(
                "can't 'pub get' if project hasn't a pubspec.yaml file")
            return
        path_to_pubspec = package.pubspec.path

        sdk = SDK()

        if not sdk.path_to_pub:
            _logger.debug("`sdk.path_to_pub` missing; aborting pub")
            return

        self.execute(
            **{
                'working_dir': os.path.dirname(path_to_pubspec),
                'cmd': [sdk.path_to_pub, 'get'],
                'preamble': 'Running pub get...\n',
            })
Ejemplo n.º 2
0
    def run(self, message):
        '''
        @message
          The message that will be displayed to the user when collecting their
            input.
        '''
        v = self.window.active_view()

        project = PubPackage.from_path(v.file_name())
        if not project:
            _logger.debug('no pubspec.yaml found - aborting')
            info = ErrorPanel()
            info.write('Could not locate pubspec.yaml file for: {}\n'
                                                    .format(v.file_name()))
            info.write('Cannot run Polymer command.')
            info.show()
            return

        if not project.has_dependency('polymer'):
            _logger.debug('no polymer dep found - aborting')
            info = ErrorPanel()
            info.write("Polymer isn't a dependency in this project.")
            info.write('Cannot run Polymer command.')
            info.show()
            return

        if not project.path_to_web:
            _logger.debug('creating web directory')
            project.make_top_level_dir('web')

        self.window.show_input_panel(message, '',
                                     self.on_done, None, None)
Ejemplo n.º 3
0
    def dart_pub_get(self, path_to_pubspec):
        path_to_pubspec = path_to_pubspec or self.window.active_view().file_name()
        if not path_to_pubspec:
            _logger.error('no pubspec specified for "pub get"')
            return

        package = PubPackage.from_path(path_to_pubspec)
        if not package:
            _logger.info("can't 'pub get' if project hasn't a pubspec.yaml file")
            return
        path_to_pubspec = package.pubspec.path

        sdk = SDK()

        if not sdk.path_to_pub:
            _logger.debug("`sdk.path_to_pub` missing; aborting pub")
            return

        self.execute(
            **{
                "working_dir": os.path.dirname(path_to_pubspec),
                "cmd": [sdk.path_to_pub, "get"],
                "preamble": "Running pub get...\n",
            }
        )
Ejemplo n.º 4
0
    def on_done(self, name):
        view = self.window.active_view()
        project = PubPackage.from_path(view.file_name())
        cmd = "pub run polymer:new_entry {}".format(name)

        # TODO(guillermooo): we cannot access the ouput panel used by exec.
        # This means we cannot print friendlier status output. Replace exec
        # with our own async process execution so that we can control its
        # output panel.
        self.execute(cmd, project.pubspec.parent)
Ejemplo n.º 5
0
    def on_done(self, name):
        view = self.window.active_view()
        project = PubPackage.from_path(view.file_name())
        cmd = "pub run polymer:new_entry {}".format(name)

        # TODO(guillermooo): we cannot access the ouput panel used by exec.
        # This means we cannot print friendlier status output. Replace exec
        # with our own async process execution so that we can control its
        # output panel.
        self.execute(cmd, project.pubspec.parent)
Ejemplo n.º 6
0
    def get_target_path(self, view):
        '''Returns the path in which the generated files belong.
        '''
        project = PubPackage.from_path(view.file_name())

        target_path = project.path_to_web
        if project.is_prefix(prefix=project.path_to_web,
                             path=view.file_name()):
            target_path = os.path.dirname(view.file_name())

        return target_path
 def testInitCanSucceed(self):
     p = PubPackage.from_path(self.d.name)
     self.assertEqual(self.d.name, p.pubspec.parent)
 def testInitCanFail(self):
     p = PubPackage.from_path('???')
     self.assertEqual(p, None)